@cogniplay/logic-games-sheet 0.0.0-stage → 0.1.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/README.md +117 -2
- package/font/generated/roboto-regular.d.ts +2 -0
- package/font/generated/roboto-regular.d.ts.map +1 -0
- package/font/generated/roboto-regular.js +4 -0
- package/font/generated/roboto-regular.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/limits.d.ts +51 -0
- package/limits.d.ts.map +1 -0
- package/limits.js +92 -0
- package/limits.js.map +1 -0
- package/package.json +27 -4
- package/pdfmake-augment.d.ts +8 -0
- package/pdfmake-augment.d.ts.map +1 -0
- package/pdfmake-augment.js +2 -0
- package/pdfmake-augment.js.map +1 -0
- package/pdfmake.d.ts +12 -0
- package/pdfmake.d.ts.map +1 -0
- package/pdfmake.js +34 -0
- package/pdfmake.js.map +1 -0
- package/sheet.d.ts +21 -0
- package/sheet.d.ts.map +1 -0
- package/sheet.js +323 -0
- package/sheet.js.map +1 -0
- package/src/font/OFL.txt +93 -0
- package/src/font/README.md +7 -0
- package/src/font/generated/roboto-regular.ts +4 -0
- package/src/index.ts +16 -0
- package/src/limits.ts +131 -0
- package/src/pdfmake-augment.ts +15 -0
- package/src/pdfmake.ts +37 -0
- package/src/sheet.ts +449 -0
- package/src/types.ts +38 -0
- package/src/wording.ts +10 -0
- package/types.d.ts +34 -0
- package/types.d.ts.map +1 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
- package/wording.d.ts +9 -0
- package/wording.d.ts.map +1 -0
- package/wording.js +9 -0
- package/wording.js.map +1 -0
package/limits.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type FairSharesInstance, type GameData } from "@cogniplay/logic-games";
|
|
2
|
+
/**
|
|
3
|
+
* The largest footprint a sheet holds, in millimetres, each way up: the printable
|
|
4
|
+
* area A4 and Letter share (210 × 279 mm) less 10 mm margins and a 40 mm band
|
|
5
|
+
* of text under the board. The content repository's validator and the
|
|
6
|
+
* backend's import assume the same numbers.
|
|
7
|
+
*/
|
|
8
|
+
export declare const boardLimitsMm: {
|
|
9
|
+
readonly upright: {
|
|
10
|
+
readonly width: 190;
|
|
11
|
+
readonly height: 219;
|
|
12
|
+
};
|
|
13
|
+
readonly sideways: {
|
|
14
|
+
readonly width: 259;
|
|
15
|
+
readonly height: 150;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export interface SizeMm {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A board's size in millimetres: its cells' bounding box at the cell size.
|
|
24
|
+
* For Fair Shares that is one grid.
|
|
25
|
+
*/
|
|
26
|
+
export declare function boardSizeMm(instance: GameData, cellSizeMm?: number): SizeMm;
|
|
27
|
+
/**
|
|
28
|
+
* The cells the pieces to place, or to share, take under or above the board,
|
|
29
|
+
* at half scale: half a cell of gap and a piece up to three cells tall.
|
|
30
|
+
*/
|
|
31
|
+
export declare const trayBandCells = 2;
|
|
32
|
+
/**
|
|
33
|
+
* How many of a Fair Shares board's grids lie side by side on its sheet: the
|
|
34
|
+
* most that fit an upright sheet, or failing that the most that fit one
|
|
35
|
+
* sideways. When no number fits either way, the renderer's own choice, so
|
|
36
|
+
* that the footprint reported is the drawing's.
|
|
37
|
+
*/
|
|
38
|
+
export declare function gridsAcross(instance: FairSharesInstance, cellSizeMm?: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* What a board takes on a sheet, in millimetres. For Amoeba that is the
|
|
41
|
+
* board. For Line Counts: its cells, a cell more across when any row has a
|
|
42
|
+
* clue, a cell more down when any column has one, and two cells more down
|
|
43
|
+
* when any piece is to place. For Fair Shares: its grids in rows of
|
|
44
|
+
* `gridsAcross`, a cell between two grids across and down, and two cells
|
|
45
|
+
* more down when any piece is to share. The content repository's validator
|
|
46
|
+
* and the backend's import compute the same from the data.
|
|
47
|
+
*/
|
|
48
|
+
export declare function footprintMm(instance: GameData, cellSizeMm?: number): SizeMm;
|
|
49
|
+
/** Which way the sheet turns for a footprint, or undefined if it fits neither way. */
|
|
50
|
+
export declare function sheetOrientation(size: SizeMm): "portrait" | "landscape" | undefined;
|
|
51
|
+
//# sourceMappingURL=limits.d.ts.map
|
package/limits.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EAMd,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;CAGhB,CAAC;AAEX,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;;GAGG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,GAAE,MAA0B,GACrC,MAAM,CAOR;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAqB/B;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,GAAE,MAA0B,GACrC,MAAM,CAUR;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,GAAE,MAA0B,GACrC,MAAM,CAiBR;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,WAAW,GAAG,SAAS,CAMtC"}
|
package/limits.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { clueBands, gridGapCells, isFairShares, isLineCounts, isPlaced, } from "@cogniplay/logic-games";
|
|
2
|
+
/**
|
|
3
|
+
* The largest footprint a sheet holds, in millimetres, each way up: the printable
|
|
4
|
+
* area A4 and Letter share (210 × 279 mm) less 10 mm margins and a 40 mm band
|
|
5
|
+
* of text under the board. The content repository's validator and the
|
|
6
|
+
* backend's import assume the same numbers.
|
|
7
|
+
*/
|
|
8
|
+
export const boardLimitsMm = {
|
|
9
|
+
upright: { width: 190, height: 219 },
|
|
10
|
+
sideways: { width: 259, height: 150 },
|
|
11
|
+
};
|
|
12
|
+
const defaultCellSizeMm = 16;
|
|
13
|
+
/**
|
|
14
|
+
* A board's size in millimetres: its cells' bounding box at the cell size.
|
|
15
|
+
* For Fair Shares that is one grid.
|
|
16
|
+
*/
|
|
17
|
+
export function boardSizeMm(instance, cellSizeMm = defaultCellSizeMm) {
|
|
18
|
+
const xs = instance.board.map(([x]) => x);
|
|
19
|
+
const ys = instance.board.map(([, y]) => y);
|
|
20
|
+
return {
|
|
21
|
+
width: (Math.max(...xs) - Math.min(...xs) + 1) * cellSizeMm,
|
|
22
|
+
height: (Math.max(...ys) - Math.min(...ys) + 1) * cellSizeMm,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The cells the pieces to place, or to share, take under or above the board,
|
|
27
|
+
* at half scale: half a cell of gap and a piece up to three cells tall.
|
|
28
|
+
*/
|
|
29
|
+
export const trayBandCells = 2;
|
|
30
|
+
/** What a Fair Shares board takes with its grids in rows of `across`. */
|
|
31
|
+
function gridsFootprintMm(instance, across, cellSizeMm) {
|
|
32
|
+
const grid = boardSizeMm(instance, cellSizeMm);
|
|
33
|
+
const down = Math.ceil(instance.shares / across);
|
|
34
|
+
const gap = gridGapCells * cellSizeMm;
|
|
35
|
+
const toShare = instance.pieces.some((piece) => !isPlaced(piece));
|
|
36
|
+
return {
|
|
37
|
+
width: across * grid.width + (across - 1) * gap,
|
|
38
|
+
height: down * grid.height +
|
|
39
|
+
(down - 1) * gap +
|
|
40
|
+
(toShare ? trayBandCells * cellSizeMm : 0),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* How many of a Fair Shares board's grids lie side by side on its sheet: the
|
|
45
|
+
* most that fit an upright sheet, or failing that the most that fit one
|
|
46
|
+
* sideways. When no number fits either way, the renderer's own choice, so
|
|
47
|
+
* that the footprint reported is the drawing's.
|
|
48
|
+
*/
|
|
49
|
+
export function gridsAcross(instance, cellSizeMm = defaultCellSizeMm) {
|
|
50
|
+
for (const limit of [boardLimitsMm.upright, boardLimitsMm.sideways]) {
|
|
51
|
+
for (let across = instance.shares; across >= 1; across--) {
|
|
52
|
+
const size = gridsFootprintMm(instance, across, cellSizeMm);
|
|
53
|
+
if (size.width <= limit.width && size.height <= limit.height) {
|
|
54
|
+
return across;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return Math.ceil(Math.sqrt(instance.shares));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* What a board takes on a sheet, in millimetres. For Amoeba that is the
|
|
62
|
+
* board. For Line Counts: its cells, a cell more across when any row has a
|
|
63
|
+
* clue, a cell more down when any column has one, and two cells more down
|
|
64
|
+
* when any piece is to place. For Fair Shares: its grids in rows of
|
|
65
|
+
* `gridsAcross`, a cell between two grids across and down, and two cells
|
|
66
|
+
* more down when any piece is to share. The content repository's validator
|
|
67
|
+
* and the backend's import compute the same from the data.
|
|
68
|
+
*/
|
|
69
|
+
export function footprintMm(instance, cellSizeMm = defaultCellSizeMm) {
|
|
70
|
+
if (isFairShares(instance)) {
|
|
71
|
+
return gridsFootprintMm(instance, gridsAcross(instance, cellSizeMm), cellSizeMm);
|
|
72
|
+
}
|
|
73
|
+
const board = boardSizeMm(instance, cellSizeMm);
|
|
74
|
+
if (!isLineCounts(instance))
|
|
75
|
+
return board;
|
|
76
|
+
const bands = clueBands(instance.clues ?? []);
|
|
77
|
+
const toPlace = instance.pieces.some((piece) => !isPlaced(piece));
|
|
78
|
+
return {
|
|
79
|
+
width: board.width + bands.left * cellSizeMm,
|
|
80
|
+
height: board.height + (bands.top + (toPlace ? trayBandCells : 0)) * cellSizeMm,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Which way the sheet turns for a footprint, or undefined if it fits neither way. */
|
|
84
|
+
export function sheetOrientation(size) {
|
|
85
|
+
const fits = (limit) => size.width <= limit.width && size.height <= limit.height;
|
|
86
|
+
if (fits(boardLimitsMm.upright))
|
|
87
|
+
return "portrait";
|
|
88
|
+
if (fits(boardLimitsMm.sideways))
|
|
89
|
+
return "landscape";
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=limits.js.map
|
package/limits.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IACpC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;CAC7B,CAAC;AAOX,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,QAAkB,EAClB,aAAqB,iBAAiB;IAEtC,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO;QACL,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,G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,CAAC,GAAG,UAAU;KAC1E,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAC9B,IAAY;IAEZ,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAC7B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IAC3D,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAAE,OAAO,UAAU,CAAC;IACnD,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;QAAE,OAAO,WAAW,CAAC;IACrD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogniplay/logic-games-sheet",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/cogniplay-tech/cogniplay-frontend.git",
|
|
8
|
+
"directory": "libs/logic-games-sheet"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"pdfmake": "^0.3.13"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@cogniplay/logic-games": "^0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"default": "./index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfmake-augment.d.ts","sourceRoot":"","sources":["src/pdfmake-augment.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,SAAS,CAAC;IAChB,MAAM,SAAS,EAAE;QACtB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAClC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;KACjE,CAAC;CACH;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfmake-augment.js","sourceRoot":"","sources":["src/pdfmake-augment.ts"],"names":[],"mappings":""}
|
package/pdfmake.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import pdfmake from "pdfmake";
|
|
2
|
+
import "./pdfmake-augment.js";
|
|
3
|
+
/** The family name the sheet's text is set in. */
|
|
4
|
+
export declare const fontName = "Roboto";
|
|
5
|
+
/**
|
|
6
|
+
* pdfmake with the font registered and its access policies set to deny,
|
|
7
|
+
* configured on the first call. A font source has to be a name in pdfmake's
|
|
8
|
+
* virtual file system; the policies are set because the sheet needs neither
|
|
9
|
+
* URLs nor local files, and pdfmake warns when they are left unset.
|
|
10
|
+
*/
|
|
11
|
+
export declare function configuredPdfmake(): typeof pdfmake;
|
|
12
|
+
//# sourceMappingURL=pdfmake.d.ts.map
|
package/pdfmake.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfmake.d.ts","sourceRoot":"","sources":["src/pdfmake.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,sBAAsB,CAAC;AAE9B,kDAAkD;AAClD,eAAO,MAAM,QAAQ,WAAW,CAAC;AAajC;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,OAAO,CAWlD"}
|
package/pdfmake.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import pdfmake from "pdfmake";
|
|
2
|
+
import { robotoRegularBase64 } from "./font/generated/roboto-regular.js";
|
|
3
|
+
import "./pdfmake-augment.js";
|
|
4
|
+
/** The family name the sheet's text is set in. */
|
|
5
|
+
export const fontName = "Roboto";
|
|
6
|
+
const fontFile = "Roboto-Regular.ttf";
|
|
7
|
+
let configured = false;
|
|
8
|
+
function decodeBase64(text) {
|
|
9
|
+
const binary = atob(text);
|
|
10
|
+
const bytes = new Uint8Array(binary.length);
|
|
11
|
+
for (let i = 0; i < binary.length; i++)
|
|
12
|
+
bytes[i] = binary.charCodeAt(i);
|
|
13
|
+
return bytes;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* pdfmake with the font registered and its access policies set to deny,
|
|
17
|
+
* configured on the first call. A font source has to be a name in pdfmake's
|
|
18
|
+
* virtual file system; the policies are set because the sheet needs neither
|
|
19
|
+
* URLs nor local files, and pdfmake warns when they are left unset.
|
|
20
|
+
*/
|
|
21
|
+
export function configuredPdfmake() {
|
|
22
|
+
if (configured)
|
|
23
|
+
return pdfmake;
|
|
24
|
+
pdfmake.virtualfs.writeFileSync(fontFile, decodeBase64(robotoRegularBase64));
|
|
25
|
+
pdfmake.addFonts({ [fontName]: { normal: fontFile } });
|
|
26
|
+
pdfmake.setUrlAccessPolicy(() => false);
|
|
27
|
+
// The browser build has no local file access and no such setter.
|
|
28
|
+
if (typeof pdfmake.setLocalAccessPolicy === "function") {
|
|
29
|
+
pdfmake.setLocalAccessPolicy(() => false);
|
|
30
|
+
}
|
|
31
|
+
configured = true;
|
|
32
|
+
return pdfmake;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=pdfmake.js.map
|
package/pdfmake.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfmake.js","sourceRoot":"","sources":["src/pdfmake.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,mBAAmB,E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js";
|
|
2
|
+
/**
|
|
3
|
+
* A sheet among several that can't print, which fails the whole PDF: its
|
|
4
|
+
* code, in front of the reason and on its own for a caller to name the
|
|
5
|
+
* board, and the sheet's own error as the cause.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SheetError extends Error {
|
|
8
|
+
/** The failing sheet's code, such as AMO-03-0005. */
|
|
9
|
+
readonly code: string;
|
|
10
|
+
constructor(code: string, cause: Error);
|
|
11
|
+
}
|
|
12
|
+
/** One instance's sheet as a one-page PDF. */
|
|
13
|
+
export declare function renderSheet(options: SheetOptions): Promise<Uint8Array>;
|
|
14
|
+
/**
|
|
15
|
+
* Several instances' sheets in one PDF, in the order given: each on a page
|
|
16
|
+
* of its own, exactly as it prints alone, turned its own way. A sheet that
|
|
17
|
+
* can't print fails the whole with a `SheetError` naming it; an empty list
|
|
18
|
+
* is an error rather than an empty PDF.
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderSheets(sheets: readonly SheetOptions[], { title }?: DocumentOptions): Promise<Uint8Array>;
|
|
21
|
+
//# sourceMappingURL=sheet.d.ts.map
|
package/sheet.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["src/sheet.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwUhE;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAKvC;AAuED,8CAA8C;AAC9C,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAE5E;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,EAAE,KAAK,EAAE,GAAE,eAAoB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAKrB"}
|
package/sheet.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { isFairShares, isLineCounts, renderBoard, } from "@cogniplay/logic-games";
|
|
2
|
+
import { boardLimitsMm, boardSizeMm, footprintMm, gridsAcross, sheetOrientation, } from "./limits.js";
|
|
3
|
+
import { configuredPdfmake, fontName } from "./pdfmake.js";
|
|
4
|
+
import { wording } from "./wording.js";
|
|
5
|
+
/** Points per millimetre: the only place the sheet leaves millimetres. */
|
|
6
|
+
const mm = (n) => (n * 72) / 25.4;
|
|
7
|
+
const marginMm = 10;
|
|
8
|
+
/**
|
|
9
|
+
* The QR code's side, and how far it sits from the page's bottom-right
|
|
10
|
+
* corner: it stands in the corner, not in the margins. A 67-character link at
|
|
11
|
+
* the lowest error correction is 33 modules, so each is 0.9 mm, and the code
|
|
12
|
+
* is about 110 pixels at 100% on a screen: what a phone reads from a screen
|
|
13
|
+
* as well as from paper. A clean print doesn't need more correction.
|
|
14
|
+
*/
|
|
15
|
+
const qrMm = 30;
|
|
16
|
+
const qrEdgeMm = 5;
|
|
17
|
+
/** The code's text is centred on the QR code's middle; 9 pt text is about 3 mm tall. Measured from the page's bottom edge to the text's top. */
|
|
18
|
+
const codeTopFromBottomMm = qrEdgeMm + qrMm / 2 + 1.5;
|
|
19
|
+
/** The band at the bottom, inside the margin, that nothing flows into: down to the code's text, with a little room. */
|
|
20
|
+
const footerMm = codeTopFromBottomMm + 1 - marginMm;
|
|
21
|
+
/** The band at the top, inside the margin, that the header draws in and nothing flows into. */
|
|
22
|
+
const headerMm = 5;
|
|
23
|
+
/** Where the flow starts, from the page's edge: under the margin and the header's band. */
|
|
24
|
+
const contentTop = marginMm + headerMm;
|
|
25
|
+
/** The title's top, from the page's edge: below the 5 mm a printer may not reach; 13 pt text is about 5.4 mm tall with its descenders. */
|
|
26
|
+
const titleTopMm = 6;
|
|
27
|
+
/** The rule under the title, from the page's edge: clear of the title's descenders, and the instruction starts 2.5 mm under it. */
|
|
28
|
+
const ruleTopMm = 12.5;
|
|
29
|
+
const ruleStyle = { lineWidth: 0.3, lineColor: "#c4c4c4" };
|
|
30
|
+
/** The least gap between the instruction and the board. */
|
|
31
|
+
const instructionGapMm = 3;
|
|
32
|
+
/** The renderer's margin around the cells for the heavy outline, which may lie in the page margin. */
|
|
33
|
+
const outlinePaddingMm = 1;
|
|
34
|
+
const pageSizes = { A4: "A4", Letter: "LETTER" };
|
|
35
|
+
/** The papers' sizes upright, in millimetres. */
|
|
36
|
+
const paperMm = { A4: [210, 297], Letter: [215.9, 279.4] };
|
|
37
|
+
/** The known values of a choice, or a message naming them. */
|
|
38
|
+
function known(table, value, what) {
|
|
39
|
+
if (!Object.hasOwn(table, value)) {
|
|
40
|
+
const names = Object.keys(table)
|
|
41
|
+
.map((k) => `"${k}"`)
|
|
42
|
+
.join(" or ");
|
|
43
|
+
throw new Error(`Unknown ${what} "${value}": ${names}`);
|
|
44
|
+
}
|
|
45
|
+
return table[value];
|
|
46
|
+
}
|
|
47
|
+
/** The renderer writes its drawing's size in millimetres on the root element. */
|
|
48
|
+
function drawingSizeMm(svg) {
|
|
49
|
+
const match = svg.match(/width="([\d.]+)mm" height="([\d.]+)mm"/);
|
|
50
|
+
if (match === null) {
|
|
51
|
+
throw new Error("The renderer's drawing has no size in millimetres");
|
|
52
|
+
}
|
|
53
|
+
return { width: Number(match[1]), height: Number(match[2]) };
|
|
54
|
+
}
|
|
55
|
+
function prepare(options) {
|
|
56
|
+
const { instance, code, instruction, language, paper, cellSizeMm, marks, pieceColours, colour = "colour", link, title, } = options;
|
|
57
|
+
const pageSize = known(pageSizes, paper, "paper");
|
|
58
|
+
if (colour !== "colour" && colour !== "greyscale") {
|
|
59
|
+
throw new Error(`Unknown colour "${String(colour)}": colour or greyscale`);
|
|
60
|
+
}
|
|
61
|
+
const { label } = known(wording, language, "language");
|
|
62
|
+
const size = boardSizeMm(instance, cellSizeMm);
|
|
63
|
+
// What the board takes with its clues and its pieces to place; for Amoeba,
|
|
64
|
+
// the board itself.
|
|
65
|
+
const footprint = footprintMm(instance, cellSizeMm);
|
|
66
|
+
const orientation = sheetOrientation(footprint);
|
|
67
|
+
if (orientation === undefined) {
|
|
68
|
+
const { upright, sideways } = boardLimitsMm;
|
|
69
|
+
const taken = footprint.width === size.width && footprint.height === size.height
|
|
70
|
+
? ""
|
|
71
|
+
: `, ${footprint.width}×${footprint.height} mm with its clues and pieces,`;
|
|
72
|
+
const what = isFairShares(instance)
|
|
73
|
+
? `${instance.shares} grids of ${size.width}×${size.height} mm, ` +
|
|
74
|
+
`${footprint.width}×${footprint.height} mm with the pieces to share, fit`
|
|
75
|
+
: `A ${size.width}×${size.height} mm board${taken} fits`;
|
|
76
|
+
throw new Error(`${what} no sheet: at most ` +
|
|
77
|
+
`${upright.width}×${upright.height} mm upright or ` +
|
|
78
|
+
`${sideways.width}×${sideways.height} mm sideways`);
|
|
79
|
+
}
|
|
80
|
+
const limit = orientation === "portrait" ? boardLimitsMm.upright : boardLimitsMm.sideways;
|
|
81
|
+
// The pieces on the board are ghosts: the child places the real ones over
|
|
82
|
+
// them. A Line Counts board's pieces to place are drawn under it at half
|
|
83
|
+
// scale, in one row as wide as the sheet allows: they say which pieces to
|
|
84
|
+
// take, and the child matches them by shape. A Fair Shares board's pieces
|
|
85
|
+
// to share are drawn the same way above its grids, which lie as many
|
|
86
|
+
// across as the footprint counted.
|
|
87
|
+
const svg = renderBoard(instance, {
|
|
88
|
+
cellSizeMm,
|
|
89
|
+
marks,
|
|
90
|
+
pieceStyle: "ghost",
|
|
91
|
+
pieceColours: colour === "colour" ? pieceColours : undefined,
|
|
92
|
+
trayScale: 0.5,
|
|
93
|
+
trayWidthMm: limit.width,
|
|
94
|
+
...(isFairShares(instance)
|
|
95
|
+
? { gridsPerRow: gridsAcross(instance, cellSizeMm) }
|
|
96
|
+
: {}),
|
|
97
|
+
});
|
|
98
|
+
const drawing = drawingSizeMm(svg);
|
|
99
|
+
// The limits count cells, but a piece or a mark off the board, or pieces to
|
|
100
|
+
// place that need a second row, make the drawing larger than the count; it
|
|
101
|
+
// must still fit the way up the footprint chose.
|
|
102
|
+
if (drawing.width - 2 * outlinePaddingMm > limit.width ||
|
|
103
|
+
drawing.height - 2 * outlinePaddingMm > limit.height) {
|
|
104
|
+
throw new Error((isFairShares(instance)
|
|
105
|
+
? `The pieces to share don't fit beside the ${instance.shares} grids of ` +
|
|
106
|
+
`${size.width}×${size.height} mm: `
|
|
107
|
+
: (isLineCounts(instance)
|
|
108
|
+
? "The clues and the pieces to place don't fit beside"
|
|
109
|
+
: "A piece or a mark lies off") +
|
|
110
|
+
` the ${size.width}×${size.height} mm board: `) +
|
|
111
|
+
`the drawing is ${drawing.width}×${drawing.height} mm, which fits no sheet ` +
|
|
112
|
+
(orientation === "portrait" ? "upright" : "sideways"));
|
|
113
|
+
}
|
|
114
|
+
const [upright, long] = paperMm[paper];
|
|
115
|
+
const [pageWidth, pageHeight] = orientation === "portrait" ? [upright, long] : [long, upright];
|
|
116
|
+
return {
|
|
117
|
+
code,
|
|
118
|
+
instruction,
|
|
119
|
+
title,
|
|
120
|
+
link,
|
|
121
|
+
label,
|
|
122
|
+
svg,
|
|
123
|
+
drawing,
|
|
124
|
+
pageSize,
|
|
125
|
+
orientation,
|
|
126
|
+
pageWidth,
|
|
127
|
+
// The instruction sits under the title; the board is centred in what the
|
|
128
|
+
// instruction and the QR code leave between them.
|
|
129
|
+
areaBottom: pageHeight - qrEdgeMm - qrMm,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* One sheet's page, as a pdfmake section: a section starts a page of its own,
|
|
134
|
+
* with its own size, orientation, header and footer, so a sheet is the same
|
|
135
|
+
* whether it prints alone or among others. The header is the variant's
|
|
136
|
+
* title; the footer is the teacher's strip: the code, and the QR code to the
|
|
137
|
+
* instance's page in the corner. The board is pushed down by the offset.
|
|
138
|
+
*/
|
|
139
|
+
function section(sheet, offsetMm) {
|
|
140
|
+
const { code, instruction, title, link, label, svg, drawing, pageWidth } = sheet;
|
|
141
|
+
return {
|
|
142
|
+
section: [
|
|
143
|
+
{ text: instruction },
|
|
144
|
+
{
|
|
145
|
+
svg,
|
|
146
|
+
width: mm(drawing.width),
|
|
147
|
+
height: mm(drawing.height),
|
|
148
|
+
alignment: "center",
|
|
149
|
+
margin: [0, mm(instructionGapMm + offsetMm), 0, 0],
|
|
150
|
+
},
|
|
151
|
+
...(link === undefined
|
|
152
|
+
? []
|
|
153
|
+
: [
|
|
154
|
+
{
|
|
155
|
+
qr: link,
|
|
156
|
+
fit: mm(qrMm),
|
|
157
|
+
eccLevel: "L",
|
|
158
|
+
absolutePosition: {
|
|
159
|
+
x: mm(pageWidth - qrEdgeMm - qrMm),
|
|
160
|
+
y: mm(sheet.areaBottom),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
]),
|
|
164
|
+
],
|
|
165
|
+
pageSize: sheet.pageSize,
|
|
166
|
+
pageOrientation: sheet.orientation,
|
|
167
|
+
// The header's box is the top margin and the band; the rule is placed
|
|
168
|
+
// within it from the page's edge, the title flows from its margin.
|
|
169
|
+
...(title === undefined
|
|
170
|
+
? {}
|
|
171
|
+
: {
|
|
172
|
+
header: {
|
|
173
|
+
stack: [
|
|
174
|
+
{
|
|
175
|
+
text: title,
|
|
176
|
+
fontSize: 13,
|
|
177
|
+
alignment: "center",
|
|
178
|
+
margin: [mm(marginMm), mm(titleTopMm), mm(marginMm), 0],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
canvas: [
|
|
182
|
+
{
|
|
183
|
+
type: "line",
|
|
184
|
+
x1: mm(marginMm),
|
|
185
|
+
y1: 0,
|
|
186
|
+
x2: mm(pageWidth - marginMm),
|
|
187
|
+
y2: 0,
|
|
188
|
+
lineWidth: mm(ruleStyle.lineWidth),
|
|
189
|
+
lineColor: ruleStyle.lineColor,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
absolutePosition: { x: 0, y: mm(ruleTopMm) },
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
footer: {
|
|
198
|
+
text: `${label} ${code}`,
|
|
199
|
+
fontSize: 9,
|
|
200
|
+
color: "#555",
|
|
201
|
+
// The footer's box is the bottom margin, marginMm + footerMm from the page's edge.
|
|
202
|
+
margin: [
|
|
203
|
+
mm(marginMm),
|
|
204
|
+
mm(marginMm + footerMm - codeTopFromBottomMm),
|
|
205
|
+
mm(marginMm),
|
|
206
|
+
0,
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The document for the sheets, each board pushed down by its offset, with
|
|
213
|
+
* where each board landed reported to `measured` as the layout goes, in the
|
|
214
|
+
* sheets' order.
|
|
215
|
+
*/
|
|
216
|
+
function definition(sheets, offsetsMm, title, measured) {
|
|
217
|
+
const [first] = sheets;
|
|
218
|
+
if (first === undefined)
|
|
219
|
+
throw new Error("No sheets to lay out");
|
|
220
|
+
return {
|
|
221
|
+
// The file's name when a viewer saves it: browsers take it from the
|
|
222
|
+
// document's title, and the sheet opens from a blob address whose name
|
|
223
|
+
// is a random id.
|
|
224
|
+
...(title === undefined ? {} : { info: { title } }),
|
|
225
|
+
pageSize: first.pageSize,
|
|
226
|
+
pageOrientation: first.orientation,
|
|
227
|
+
pageMargins: [
|
|
228
|
+
mm(marginMm),
|
|
229
|
+
mm(contentTop),
|
|
230
|
+
mm(marginMm),
|
|
231
|
+
mm(marginMm + footerMm),
|
|
232
|
+
],
|
|
233
|
+
defaultStyle: { font: fontName, fontSize: 11 },
|
|
234
|
+
content: sheets.map((sheet, index) => section(sheet, offsetsMm[index] ?? 0)),
|
|
235
|
+
// pdfmake reports every node here with its properties, once each and in
|
|
236
|
+
// the document's order, so the boards are the nodes with an svg.
|
|
237
|
+
pageBreakBefore: (node) => {
|
|
238
|
+
if (node.svg !== undefined) {
|
|
239
|
+
measured.push({
|
|
240
|
+
boardPage: node.startPosition.pageNumber,
|
|
241
|
+
boardTopMm: node.startPosition.top / mm(1),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A sheet among several that can't print, which fails the whole PDF: its
|
|
250
|
+
* code, in front of the reason and on its own for a caller to name the
|
|
251
|
+
* board, and the sheet's own error as the cause.
|
|
252
|
+
*/
|
|
253
|
+
export class SheetError extends Error {
|
|
254
|
+
/** The failing sheet's code, such as AMO-03-0005. */
|
|
255
|
+
code;
|
|
256
|
+
constructor(code, cause) {
|
|
257
|
+
super(`${code}: ${cause.message}`, { cause });
|
|
258
|
+
this.name = "SheetError";
|
|
259
|
+
this.code = code;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The sheets in one PDF, a page each. A sheet that can't print fails the
|
|
264
|
+
* whole; with `named`, its error becomes a `SheetError` naming it, since
|
|
265
|
+
* among many the caller can't tell which it was.
|
|
266
|
+
*/
|
|
267
|
+
async function render(sheets, title, named) {
|
|
268
|
+
const checked = (code, check) => {
|
|
269
|
+
try {
|
|
270
|
+
return check();
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
if (!named || !(error instanceof Error))
|
|
274
|
+
throw error;
|
|
275
|
+
throw new SheetError(code, error);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const prepared = sheets.map((sheet) => checked(sheet.code, () => prepare(sheet)));
|
|
279
|
+
// pdfmake lays out top-down, so the sheets are laid out twice: once to
|
|
280
|
+
// measure where each board lands under its instruction, and once with each
|
|
281
|
+
// board pushed down by half the room left on its page.
|
|
282
|
+
const measured = [];
|
|
283
|
+
await configuredPdfmake()
|
|
284
|
+
.createPdf(definition(prepared, prepared.map(() => 0), title, measured))
|
|
285
|
+
.getStream();
|
|
286
|
+
const offsetsMm = prepared.map((sheet, index) => checked(sheet.code, () => {
|
|
287
|
+
const board = measured[index];
|
|
288
|
+
const room = board === undefined
|
|
289
|
+
? -1
|
|
290
|
+
: sheet.areaBottom - board.boardTopMm - sheet.drawing.height;
|
|
291
|
+
// Sheet n is page n, unless its instruction pushed its board onto the
|
|
292
|
+
// next one.
|
|
293
|
+
if (board?.boardPage !== index + 1 || room < 0) {
|
|
294
|
+
throw new Error(`The instruction (${sheet.instruction.length} characters) is too long for a board this tall`);
|
|
295
|
+
}
|
|
296
|
+
return room / 2;
|
|
297
|
+
}));
|
|
298
|
+
const created = configuredPdfmake().createPdf(definition(prepared, offsetsMm, title, []));
|
|
299
|
+
const doc = (await created.getStream());
|
|
300
|
+
// Ask viewers not to scale the page. PDFKit 0.20 ends the ViewerPreferences
|
|
301
|
+
// reference itself in end(), so it must not be ended here.
|
|
302
|
+
const root = doc._root.data;
|
|
303
|
+
root.ViewerPreferences ??= doc.ref({});
|
|
304
|
+
root.ViewerPreferences.data.PrintScaling = "None";
|
|
305
|
+
return await created.getBuffer();
|
|
306
|
+
}
|
|
307
|
+
/** One instance's sheet as a one-page PDF. */
|
|
308
|
+
export async function renderSheet(options) {
|
|
309
|
+
return await render([options], options.code, false);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Several instances' sheets in one PDF, in the order given: each on a page
|
|
313
|
+
* of its own, exactly as it prints alone, turned its own way. A sheet that
|
|
314
|
+
* can't print fails the whole with a `SheetError` naming it; an empty list
|
|
315
|
+
* is an error rather than an empty PDF.
|
|
316
|
+
*/
|
|
317
|
+
export async function renderSheets(sheets, { title } = {}) {
|
|
318
|
+
if (sheets.length === 0) {
|
|
319
|
+
throw new Error("No sheets to render: a document needs at least one");
|
|
320
|
+
}
|
|
321
|
+
return await render(sheets, title, true);
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=sheet.js.map
|
package/sheet.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.js","sourceRoot":"","sources":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