@cogniplay/logic-games-sheet 0.5.0 → 0.7.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 +8 -5
- package/limits.d.ts +8 -5
- package/limits.d.ts.map +1 -1
- package/limits.js +16 -6
- package/limits.js.map +1 -1
- package/package.json +2 -2
- package/sheet.d.ts +3 -2
- package/sheet.d.ts.map +1 -1
- package/sheet.js +119 -43
- package/sheet.js.map +1 -1
- package/src/limits.ts +17 -5
- package/src/sheet.ts +166 -48
- package/src/wording.ts +6 -5
- package/wording.d.ts +4 -2
- package/wording.d.ts.map +1 -1
- package/wording.js +5 -4
- package/wording.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @cogniplay/logic-games-sheet
|
|
2
2
|
|
|
3
|
-
Makes the child's printed sheet for a logic-game instance: a one
|
|
3
|
+
Makes the child's printed sheet for a logic-game instance: a PDF of one page (two for a Rearrange the Pieces board, whose second is the goal picture) with the board at the exact size of the kit's pieces, the variant's title, the instance's instruction and the instance's code. For a Line Counts, a Build a Bridge, a Fill the Shape or a Build the Mirror Image board it also shows the pieces to place, for a Fair Shares board the pieces to share, and for a Find the Hidden Shapes board the hidden pieces and the questions asked. The same function serves the content repository's play-test prints in Node and, later, the `/edu` print button in the browser.
|
|
4
4
|
|
|
5
5
|
It builds on `@cogniplay/logic-games`, which draws the board, and on pdfmake 0.3, which lays the page out and embeds the font. The designs are in `docs/superpowers/specs/2026-11-05-logic-games-sheet-design.md`, `docs/superpowers/specs/2026-11-10-line-counts-drawing-design.md`, `docs/superpowers/specs/2026-11-11-fair-shares-drawing-design.md`, `docs/superpowers/specs/2026-11-17-build-a-bridge-drawing-design.md`, `docs/superpowers/specs/2026-11-24-fill-the-shape-drawing-design.md` and `docs/superpowers/specs/2026-11-26-build-the-mirror-image-drawing-design.md`.
|
|
6
6
|
|
|
@@ -52,19 +52,19 @@ import { renderSheets } from "@cogniplay/logic-games-sheet";
|
|
|
52
52
|
const bytes = await renderSheets([first, second, third], { title: "Tuesday, year 3" });
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
`renderSheets` takes a list of the same options and puts each sheet on a page of its own, in the order given, exactly as it prints alone: its own paper, turned its own way, with its own title, code and QR code. Each
|
|
55
|
+
`renderSheets` takes a list of the same options and puts each sheet on a page of its own (two for a Rearrange the Pieces board), in the order given, exactly as it prints alone: its own paper, turned its own way, with its own title, code and QR code. Each printed page is a pdfmake section, and `renderSheet` makes its one sheet the same way, so a sheet is the same alone or among others. `title` is the document's, which a viewer names a saved file by; there is none without it. A sheet that can't print fails the whole with a `SheetError`: its `code` is that sheet's code, its message is the code before the reason, and its `cause` is the sheet's own error, so a caller can name the board. An empty list is an error rather than an empty PDF. `renderSheet`'s errors are the sheet's own, without a code, since the caller knows which sheet it asked for. A hundred sheets of mixed games and orientations take about a second and a quarter in a browser on a recent laptop and make a PDF of under 1 MB.
|
|
56
56
|
|
|
57
57
|
### What the sheet holds
|
|
58
58
|
|
|
59
|
-
One page, A4 or Letter, with 10 mm margins. From the top: the variant's title, when one is given; the instruction; the board, drawn by the renderer at the cell size and centred in the room left; and at the bottom the code with a label and, when a link is given, a QR code to the instance's page. The page is portrait when the board fits upright and landscape otherwise.
|
|
59
|
+
One page (a Rearrange the Pieces board two, below), A4 or Letter, with 10 mm margins. From the top: the variant's title, when one is given; the instruction; the board, drawn by the renderer at the cell size and centred in the room left; and at the bottom the code with a label and, when a link is given, a QR code to the instance's page. The page is portrait when the board fits upright and landscape otherwise.
|
|
60
60
|
|
|
61
|
-
The pieces on the board print as ghosts, thin outlines with light stripes, since the child covers them with the real pieces. A Line Counts board's clues print beside it, and its pieces to place print under it at half scale, as tiles in the kit's colours or in grey: they say which pieces to take, and the child matches them by shape. A Fair Shares board's grids print at true size, as many side by side as fit, with its pieces to share above them at half scale in the same way. Nothing on its sheet marks a place for a piece to leave out, and nothing prints the shares' sizes or the difference to reach. A Build a Bridge board prints at true size with its circles and squares, any piece already in place solid grey, and its pieces to place under it at half scale as Line Counts' are; with two paths each carries its path's symbol. A Fill the Shape board prints as a Build a Bridge board does, without marks or symbols: the outline at true size with its holes hatched. A Build the Mirror Image board prints as a Fill the Shape board does, with the pattern's grid beside it: the grey pattern, the axis or the point O, the empty board and any piece already in place solid grey, at true size, and the pieces to place under both grids. A No Way Back board prints its start: the board with its holes hatched, the pieces at their starts as ghosts with their letters, A and B, and each target dashed with its piece's letter; no X.
|
|
61
|
+
The pieces on the board print as ghosts, thin outlines with light stripes, since the child covers them with the real pieces. A Line Counts board's clues print beside it, and its pieces to place print under it at half scale, as tiles in the kit's colours or in grey: they say which pieces to take, and the child matches them by shape. A Fair Shares board's grids print at true size, as many side by side as fit, with its pieces to share above them at half scale in the same way. Nothing on its sheet marks a place for a piece to leave out, and nothing prints the shares' sizes or the difference to reach. A Build a Bridge board prints at true size with its circles and squares, any piece already in place solid grey, and its pieces to place under it at half scale as Line Counts' are; with two paths each carries its path's symbol. A Fill the Shape board prints as a Build a Bridge board does, without marks or symbols: the outline at true size with its holes hatched. A Build the Mirror Image board prints as a Fill the Shape board does, with the pattern's grid beside it: the grey pattern, the axis or the point O, the empty board and any piece already in place solid grey, at true size, and the pieces to place under both grids. A No Way Back board prints its start: the board with its holes hatched, the pieces at their starts as ghosts with their letters, A and B, and each target dashed with its piece's letter; no X. A Rearrange the Pieces board prints two pages: its start as a No Way Back board's, the pieces lettered A to E; then its goal picture, the same board at the same size, at the same height and the same way up, with only the targeted pieces, each on its target with its letter, so the goal stays in view when the real pieces cover the start. The goal page is headed "Goal" ("Cél") where the first page has the title, has no instruction, and has the first page's footer. A Find the Hidden Shapes board prints its start in the format's one layout: the board at true size, empty for the real pieces, with its row numbers on its left and its column letters under it; a cell search's marks on it, a circle for empty, a tick for a hit, or the hit piece's letter; the hidden pieces under it at half scale, lettered A and B; and a trial search's trials under them at half size, three to a row, each with its number and answer above it. Nothing on it asks the child to write or draw.
|
|
62
62
|
|
|
63
63
|
The PDF states its sizes in physical units and asks viewers not to scale it (`PrintScaling: None`). For viewers that ignore that, Edu tells the teacher to print at actual size.
|
|
64
64
|
|
|
65
65
|
### The limits
|
|
66
66
|
|
|
67
|
-
A sheet holds a footprint of at most 190×219 mm upright or 259×150 mm sideways, the same numbers the content repository's validator and the backend's import assume. For Amoeba
|
|
67
|
+
A sheet holds a footprint of at most 190×219 mm upright or 259×150 mm sideways, the same numbers the content repository's validator and the backend's import assume. For Amoeba, No Way Back and Rearrange the Pieces the footprint is the board: every piece starts on it and the targets lie on it. A Rearrange the Pieces goal page has the same box, and its heading sits in the header, outside the area the footprint measures. For Line Counts it is:
|
|
68
68
|
|
|
69
69
|
- width = (columns + 1 if any row has a clue) × cell size
|
|
70
70
|
- height = (rows + 1 if any column has a clue + 2 if any piece is to place) × cell size
|
|
@@ -84,6 +84,8 @@ Fill the Shape's footprint is Build a Bridge's. The first round's outlines lie i
|
|
|
84
84
|
|
|
85
85
|
For Build the Mirror Image the footprint is the bounding box of the board and its image, the pattern's grid, with any gap the data leaves at the axis; the axis's 3 mm past both its ends, 6 mm more down for a vertical axis and 6 mm more across for a horizontal one, nothing for a half turn's point; and two cells more down when any piece is to place. A board that fits both ways prints upright: three upright bars of 4, 3 and 2 beside a vertical axis take 160×134 mm. The largest vertical layouts print sideways, such as the handbook's T2-SQ with its gap, 256×134 mm, and the tallest, 7 rows and the pieces to place, takes all 150 mm; the horizontal axis's prints upright, 118×192 mm. The handbook's own T3-SQ layout, 7×16 cells, fits neither way, nor does a 16×3 board under a horizontal axis with pieces to place: 262 mm across.
|
|
86
86
|
|
|
87
|
+
For Find the Hidden Shapes the footprint is the format's one layout, counted in half cells (`seekFootprint` in the renderer): the board at full size with a half cell for its row numbers and one for its letters, four for the tray, and for each row of trials a half cell of gap, one for the captions and the board's height at half size, three trials to a row in slots at least six half cells wide, one apart. A 3×3 cell search takes 56×88 mm; a 1×4 board with bar4, 32×104 mm, its tray wider than the board; a 5×4 board with six trials, 160×200 mm. Every board of this round prints upright. The drawing is the footprint exactly, so its pieces never overrun it; 4×4 with seven trials, 160×248 mm, fits neither way.
|
|
88
|
+
|
|
87
89
|
To tell ahead of time:
|
|
88
90
|
|
|
89
91
|
```ts
|
|
@@ -103,6 +105,7 @@ boardLimitsMm; // { upright: { width: 190, height: 219 }, sideways: { width: 259
|
|
|
103
105
|
- a Line Counts board whose pieces to place need more than the two cells counted for them, such as a second row: `The clues and the pieces to place don't fit beside the 160×160 mm board: the drawing is 178×238 mm, which fits no sheet upright`;
|
|
104
106
|
- a Build a Bridge or a Fill the Shape board in the same case: `The pieces to place don't fit beside the 144×176 mm board: …`;
|
|
105
107
|
- a Build the Mirror Image board too big with its image: `A 112×96 mm board, 118×256 mm with its image, the axis's 3 mm past both ends, and the pieces to place, fits no sheet: …`, and one whose pieces need a second row: `The pieces to place don't fit beside the 112×80 mm board and its image: …`;
|
|
108
|
+
- a Find the Hidden Shapes board too big: `A 64×64 mm board, 160×248 mm with its addresses, the pieces and 7 trials, fits no sheet: …`, or for a cell search `… with its addresses and the pieces, fits no sheet: …`;
|
|
106
109
|
- a Fair Shares board in the same case: `The pieces to share don't fit beside the 3 grids of 80×80 mm: the drawing is 178×238 mm, which fits no sheet upright`;
|
|
107
110
|
- an instruction so long it leaves the board no room: `The instruction (1200 characters) is too long for a board this tall`. Nothing caps the instruction in the format; the content repository's validator runs the sheet for every instance and reports this failure, so the sheet fails here and never shrinks or clips the text.
|
|
108
111
|
|
package/limits.d.ts
CHANGED
|
@@ -49,9 +49,9 @@ export declare const trayBandCells = 2;
|
|
|
49
49
|
*/
|
|
50
50
|
export declare function gridsAcross(instance: FairSharesInstance, cellSizeMm?: number): number;
|
|
51
51
|
/**
|
|
52
|
-
* What a board takes on a sheet, in millimetres. For Amoeba
|
|
53
|
-
* that is the board:
|
|
54
|
-
* targets lie on it. For Line Counts: its cells, a cell more across when any row has a
|
|
52
|
+
* What a board takes on a sheet, in millimetres. For Amoeba, No Way Back and
|
|
53
|
+
* Rearrange the Pieces that is the board: their pieces start on it, and the
|
|
54
|
+
* targets lie on it; a Rearrange the Pieces goal page has the same box. For Line Counts: its cells, a cell more across when any row has a
|
|
55
55
|
* clue, a cell more down when any column has one, and two cells more down
|
|
56
56
|
* when any piece is to place. For Fair Shares: its grids in rows of
|
|
57
57
|
* `gridsAcross`, a cell between two grids across and down, and two cells
|
|
@@ -60,8 +60,11 @@ export declare function gridsAcross(instance: FairSharesInstance, cellSizeMm?: n
|
|
|
60
60
|
* Build the Mirror Image: the bounding box of the board and its image, the
|
|
61
61
|
* axis's 3 mm past both its ends, 6 mm more down for a vertical axis and
|
|
62
62
|
* across for a horizontal one, and two cells more down when any piece is to
|
|
63
|
-
* place.
|
|
64
|
-
*
|
|
63
|
+
* place. For Find the Hidden Shapes: the format's one layout, in half
|
|
64
|
+
* cells at half the cell size, `seekFootprint`: the board with its row
|
|
65
|
+
* numbers and letters, the tray of its hidden pieces and a trial search's
|
|
66
|
+
* trials. The content repository's validator and the backend's import
|
|
67
|
+
* compute the same from the data.
|
|
65
68
|
*/
|
|
66
69
|
export declare function footprintMm(instance: GameData, cellSizeMm?: number): SizeMm;
|
|
67
70
|
/** Which way the sheet turns for a footprint, or undefined if it fits neither way. */
|
package/limits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,cAAc,EAYpB,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;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,cAAc,EACxB,UAAU,GAAE,MAA0B,GACrC,MAAM,CAWR;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B;;;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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,GAAE,MAA0B,GACrC,MAAM,CA4CR;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,WAAW,GAAG,SAAS,CAMtC"}
|
package/limits.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clueBands, gridGapCells, imageOf, isFairShares, isFill, isLineCounts, isLinks, isMirror, isPlaced, } from "@cogniplay/logic-games";
|
|
1
|
+
import { clueBands, gridGapCells, imageOf, isFairShares, isFill, isLineCounts, isLinks, isMirror, isPlaced, isSeek, seekFootprint, } from "@cogniplay/logic-games";
|
|
2
2
|
/**
|
|
3
3
|
* The largest footprint a sheet holds, in millimetres, each way up: the printable
|
|
4
4
|
* area A4 and Letter share (210 × 279 mm) less 10 mm margins and a 40 mm band
|
|
@@ -81,9 +81,9 @@ export function gridsAcross(instance, cellSizeMm = defaultCellSizeMm) {
|
|
|
81
81
|
return Math.ceil(Math.sqrt(instance.shares));
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* What a board takes on a sheet, in millimetres. For Amoeba
|
|
85
|
-
* that is the board:
|
|
86
|
-
* targets lie on it. For Line Counts: its cells, a cell more across when any row has a
|
|
84
|
+
* What a board takes on a sheet, in millimetres. For Amoeba, No Way Back and
|
|
85
|
+
* Rearrange the Pieces that is the board: their pieces start on it, and the
|
|
86
|
+
* targets lie on it; a Rearrange the Pieces goal page has the same box. For Line Counts: its cells, a cell more across when any row has a
|
|
87
87
|
* clue, a cell more down when any column has one, and two cells more down
|
|
88
88
|
* when any piece is to place. For Fair Shares: its grids in rows of
|
|
89
89
|
* `gridsAcross`, a cell between two grids across and down, and two cells
|
|
@@ -92,13 +92,23 @@ export function gridsAcross(instance, cellSizeMm = defaultCellSizeMm) {
|
|
|
92
92
|
* Build the Mirror Image: the bounding box of the board and its image, the
|
|
93
93
|
* axis's 3 mm past both its ends, 6 mm more down for a vertical axis and
|
|
94
94
|
* across for a horizontal one, and two cells more down when any piece is to
|
|
95
|
-
* place.
|
|
96
|
-
*
|
|
95
|
+
* place. For Find the Hidden Shapes: the format's one layout, in half
|
|
96
|
+
* cells at half the cell size, `seekFootprint`: the board with its row
|
|
97
|
+
* numbers and letters, the tray of its hidden pieces and a trial search's
|
|
98
|
+
* trials. The content repository's validator and the backend's import
|
|
99
|
+
* compute the same from the data.
|
|
97
100
|
*/
|
|
98
101
|
export function footprintMm(instance, cellSizeMm = defaultCellSizeMm) {
|
|
99
102
|
if (isFairShares(instance)) {
|
|
100
103
|
return gridsFootprintMm(instance, gridsAcross(instance, cellSizeMm), cellSizeMm);
|
|
101
104
|
}
|
|
105
|
+
if (isSeek(instance)) {
|
|
106
|
+
const { width, height } = seekFootprint(instance);
|
|
107
|
+
return {
|
|
108
|
+
width: (width * cellSizeMm) / 2,
|
|
109
|
+
height: (height * cellSizeMm) / 2,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
102
112
|
if (isMirror(instance)) {
|
|
103
113
|
const grids = gridsSizeMm(instance, cellSizeMm);
|
|
104
114
|
const ends = axisEndsMm;
|
package/limits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,GACd,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,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;QAC3D,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CA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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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogniplay/logic-games-sheet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pdfmake": "^0.3.13"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@cogniplay/logic-games": "^0.
|
|
18
|
+
"@cogniplay/logic-games": "^0.7.0"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
package/sheet.d.ts
CHANGED
|
@@ -9,11 +9,12 @@ export declare class SheetError extends Error {
|
|
|
9
9
|
readonly code: string;
|
|
10
10
|
constructor(code: string, cause: Error);
|
|
11
11
|
}
|
|
12
|
-
/** One instance's sheet as a one
|
|
12
|
+
/** One instance's sheet as a PDF: one page, or two for a Rearrange the Pieces board, its start and its goal. */
|
|
13
13
|
export declare function renderSheet(options: SheetOptions): Promise<Uint8Array>;
|
|
14
14
|
/**
|
|
15
15
|
* Several instances' sheets in one PDF, in the order given: each on a page
|
|
16
|
-
* of its own,
|
|
16
|
+
* of its own, two for a Rearrange the Pieces board, exactly as it prints
|
|
17
|
+
* alone, turned its own way. A sheet that
|
|
17
18
|
* can't print fails the whole with a `SheetError` naming it; an empty list
|
|
18
19
|
* is an error rather than an empty PDF.
|
|
19
20
|
*/
|
package/sheet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["src/sheet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["src/sheet.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6ahE;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAKvC;AAgGD,gHAAgH;AAChH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAE5E;AAED;;;;;;GAMG;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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFairShares, isFill, isLineCounts, isLinks, isMirror, renderBoard, } from "@cogniplay/logic-games";
|
|
1
|
+
import { isFairShares, isFill, isLineCounts, isLinks, isMirror, isRearrange, isSeek, renderBoard, renderGoal, } from "@cogniplay/logic-games";
|
|
2
2
|
import { boardLimitsMm, boardSizeMm, footprintMm, gridsAcross, sheetOrientation, } from "./limits.js";
|
|
3
3
|
import { configuredPdfmake, fontName } from "./pdfmake.js";
|
|
4
4
|
import { wording } from "./wording.js";
|
|
@@ -58,7 +58,7 @@ function prepare(options) {
|
|
|
58
58
|
if (colour !== "colour" && colour !== "greyscale") {
|
|
59
59
|
throw new Error(`Unknown colour "${String(colour)}": colour or greyscale`);
|
|
60
60
|
}
|
|
61
|
-
const { label } = known(wording, language, "language");
|
|
61
|
+
const { label, goal: goalHeading } = known(wording, language, "language");
|
|
62
62
|
const size = boardSizeMm(instance, cellSizeMm);
|
|
63
63
|
// What the board takes with its clues and its pieces to place; for Amoeba,
|
|
64
64
|
// the board itself.
|
|
@@ -68,13 +68,20 @@ function prepare(options) {
|
|
|
68
68
|
const { upright, sideways } = boardLimitsMm;
|
|
69
69
|
const taken = footprint.width === size.width && footprint.height === size.height
|
|
70
70
|
? ""
|
|
71
|
-
:
|
|
72
|
-
? `, ${footprint.width}×${footprint.height} mm with its
|
|
73
|
-
(instance.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
: isSeek(instance)
|
|
72
|
+
? `, ${footprint.width}×${footprint.height} mm with its addresses` +
|
|
73
|
+
(instance.search.kind === "trial" &&
|
|
74
|
+
instance.search.questions.length > 0
|
|
75
|
+
? `, the pieces and ${instance.search.questions.length} ` +
|
|
76
|
+
(instance.search.questions.length === 1 ? "trial," : "trials,")
|
|
77
|
+
: " and the pieces,")
|
|
78
|
+
: isMirror(instance)
|
|
79
|
+
? `, ${footprint.width}×${footprint.height} mm with its image, ` +
|
|
80
|
+
(instance.transform.kind === "half-turn"
|
|
81
|
+
? ""
|
|
82
|
+
: "the axis's 3 mm past both ends, ") +
|
|
83
|
+
"and the pieces to place,"
|
|
84
|
+
: `, ${footprint.width}×${footprint.height} mm with its clues and pieces,`;
|
|
78
85
|
const what = isFairShares(instance)
|
|
79
86
|
? `${instance.shares} grids of ${size.width}×${size.height} mm, ` +
|
|
80
87
|
`${footprint.width}×${footprint.height} mm with the pieces to share, fit`
|
|
@@ -96,8 +103,13 @@ function prepare(options) {
|
|
|
96
103
|
// and a Build the Mirror Image board as Fill the Shape's, with its
|
|
97
104
|
// pattern's grid, its pattern and its axis beside it. A No Way Back board
|
|
98
105
|
// prints its start: the pieces as ghosts with their letters, the targets
|
|
99
|
-
// dashed, no X.
|
|
100
|
-
|
|
106
|
+
// dashed, no X. A Rearrange the Pieces board prints its start as No Way
|
|
107
|
+
// Back's, and on a second page its goal picture, the start's size. A Find
|
|
108
|
+
// the Hidden Shapes board prints its start in its own one layout: the
|
|
109
|
+
// board with its addresses and marks, the hidden pieces at half scale
|
|
110
|
+
// under it and the trials at half size, the footprint exactly, whatever
|
|
111
|
+
// the tray's options say.
|
|
112
|
+
const renderOptions = {
|
|
101
113
|
cellSizeMm,
|
|
102
114
|
marks,
|
|
103
115
|
pieceStyle: "ghost",
|
|
@@ -107,8 +119,12 @@ function prepare(options) {
|
|
|
107
119
|
...(isFairShares(instance)
|
|
108
120
|
? { gridsPerRow: gridsAcross(instance, cellSizeMm) }
|
|
109
121
|
: {}),
|
|
110
|
-
}
|
|
122
|
+
};
|
|
123
|
+
const svg = renderBoard(instance, renderOptions);
|
|
111
124
|
const drawing = drawingSizeMm(svg);
|
|
125
|
+
const goal = isRearrange(instance)
|
|
126
|
+
? { heading: goalHeading, svg: renderGoal(instance, renderOptions) }
|
|
127
|
+
: undefined;
|
|
112
128
|
// The limits count cells, but a piece or a mark off the board, or pieces to
|
|
113
129
|
// place that need a second row, make the drawing larger than the count; it
|
|
114
130
|
// must still fit the way up the footprint chose.
|
|
@@ -137,6 +153,7 @@ function prepare(options) {
|
|
|
137
153
|
label,
|
|
138
154
|
svg,
|
|
139
155
|
drawing,
|
|
156
|
+
goal,
|
|
140
157
|
pageSize,
|
|
141
158
|
orientation,
|
|
142
159
|
pageWidth,
|
|
@@ -153,17 +170,43 @@ function prepare(options) {
|
|
|
153
170
|
* instance's page in the corner. The board is pushed down by the offset.
|
|
154
171
|
*/
|
|
155
172
|
function section(sheet, offsetMm) {
|
|
156
|
-
const {
|
|
173
|
+
const { instruction, title, svg, drawing } = sheet;
|
|
174
|
+
return page(sheet, [
|
|
175
|
+
{ text: instruction },
|
|
176
|
+
{
|
|
177
|
+
svg,
|
|
178
|
+
width: mm(drawing.width),
|
|
179
|
+
height: mm(drawing.height),
|
|
180
|
+
alignment: "center",
|
|
181
|
+
margin: [0, mm(instructionGapMm + offsetMm), 0, 0],
|
|
182
|
+
},
|
|
183
|
+
], title);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A Rearrange the Pieces sheet's second page: the goal picture, the start's
|
|
187
|
+
* size, under the heading "Goal" in the header's place, where the first
|
|
188
|
+
* page has the title, so it lies outside the area the footprint measures.
|
|
189
|
+
* No instruction; the offset sets the board at the start's height. The
|
|
190
|
+
* footer is the first page's.
|
|
191
|
+
*/
|
|
192
|
+
function goalSection(sheet, goal, offsetMm) {
|
|
193
|
+
const { drawing } = sheet;
|
|
194
|
+
return page(sheet, [
|
|
195
|
+
{
|
|
196
|
+
svg: goal.svg,
|
|
197
|
+
width: mm(drawing.width),
|
|
198
|
+
height: mm(drawing.height),
|
|
199
|
+
alignment: "center",
|
|
200
|
+
margin: [0, mm(offsetMm), 0, 0],
|
|
201
|
+
},
|
|
202
|
+
], goal.heading);
|
|
203
|
+
}
|
|
204
|
+
/** A page of a sheet: what it flows, its header's text if any, and the sheet's footer. */
|
|
205
|
+
function page(sheet, flow, heading) {
|
|
206
|
+
const { code, link, label, pageWidth } = sheet;
|
|
157
207
|
return {
|
|
158
208
|
section: [
|
|
159
|
-
|
|
160
|
-
{
|
|
161
|
-
svg,
|
|
162
|
-
width: mm(drawing.width),
|
|
163
|
-
height: mm(drawing.height),
|
|
164
|
-
alignment: "center",
|
|
165
|
-
margin: [0, mm(instructionGapMm + offsetMm), 0, 0],
|
|
166
|
-
},
|
|
209
|
+
...flow,
|
|
167
210
|
...(link === undefined
|
|
168
211
|
? []
|
|
169
212
|
: [
|
|
@@ -182,13 +225,13 @@ function section(sheet, offsetMm) {
|
|
|
182
225
|
pageOrientation: sheet.orientation,
|
|
183
226
|
// The header's box is the top margin and the band; the rule is placed
|
|
184
227
|
// within it from the page's edge, the title flows from its margin.
|
|
185
|
-
...(
|
|
228
|
+
...(heading === undefined
|
|
186
229
|
? {}
|
|
187
230
|
: {
|
|
188
231
|
header: {
|
|
189
232
|
stack: [
|
|
190
233
|
{
|
|
191
|
-
text:
|
|
234
|
+
text: heading,
|
|
192
235
|
fontSize: 13,
|
|
193
236
|
alignment: "center",
|
|
194
237
|
margin: [mm(marginMm), mm(titleTopMm), mm(marginMm), 0],
|
|
@@ -224,10 +267,16 @@ function section(sheet, offsetMm) {
|
|
|
224
267
|
},
|
|
225
268
|
};
|
|
226
269
|
}
|
|
270
|
+
function pagesOf(sheets) {
|
|
271
|
+
return sheets.flatMap((sheet, index) => [
|
|
272
|
+
{ sheet: index, goal: false },
|
|
273
|
+
...(sheet.goal === undefined ? [] : [{ sheet: index, goal: true }]),
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
227
276
|
/**
|
|
228
|
-
* The document for the sheets, each board pushed down by its
|
|
229
|
-
* where each board landed reported to `measured` as the layout
|
|
230
|
-
*
|
|
277
|
+
* The document for the sheets' pages, each board pushed down by its page's
|
|
278
|
+
* offset, with where each board landed reported to `measured` as the layout
|
|
279
|
+
* goes, in the pages' order.
|
|
231
280
|
*/
|
|
232
281
|
function definition(sheets, offsetsMm, title, measured) {
|
|
233
282
|
const [first] = sheets;
|
|
@@ -247,7 +296,13 @@ function definition(sheets, offsetsMm, title, measured) {
|
|
|
247
296
|
mm(marginMm + footerMm),
|
|
248
297
|
],
|
|
249
298
|
defaultStyle: { font: fontName, fontSize: 11 },
|
|
250
|
-
content: sheets.map((sheet
|
|
299
|
+
content: pagesOf(sheets).map(({ sheet: index, goal }, page) => {
|
|
300
|
+
const sheet = sheets[index];
|
|
301
|
+
const offset = offsetsMm[page] ?? 0;
|
|
302
|
+
return goal && sheet.goal !== undefined
|
|
303
|
+
? goalSection(sheet, sheet.goal, offset)
|
|
304
|
+
: section(sheet, offset);
|
|
305
|
+
}),
|
|
251
306
|
// pdfmake reports every node here with its properties, once each and in
|
|
252
307
|
// the document's order, so the boards are the nodes with an svg.
|
|
253
308
|
pageBreakBefore: (node) => {
|
|
@@ -276,7 +331,7 @@ export class SheetError extends Error {
|
|
|
276
331
|
}
|
|
277
332
|
}
|
|
278
333
|
/**
|
|
279
|
-
* The sheets in one PDF, a page each. A sheet that can't print fails the
|
|
334
|
+
* The sheets in one PDF, a page each, a Rearrange the Pieces board two. A sheet that can't print fails the
|
|
280
335
|
* whole; with `named`, its error becomes a `SheetError` naming it, since
|
|
281
336
|
* among many the caller can't tell which it was.
|
|
282
337
|
*/
|
|
@@ -294,23 +349,43 @@ async function render(sheets, title, named) {
|
|
|
294
349
|
const prepared = sheets.map((sheet) => checked(sheet.code, () => prepare(sheet)));
|
|
295
350
|
// pdfmake lays out top-down, so the sheets are laid out twice: once to
|
|
296
351
|
// measure where each board lands under its instruction, and once with each
|
|
297
|
-
// board pushed down by half the room left on its page.
|
|
352
|
+
// board pushed down by half the room left on its page. A goal page's board
|
|
353
|
+
// is pushed down to its start's height.
|
|
354
|
+
const pages = pagesOf(prepared);
|
|
298
355
|
const measured = [];
|
|
299
356
|
await configuredPdfmake()
|
|
300
|
-
.createPdf(definition(prepared,
|
|
357
|
+
.createPdf(definition(prepared, pages.map(() => 0), title, measured))
|
|
301
358
|
.getStream();
|
|
302
|
-
const offsetsMm =
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
|
|
359
|
+
const offsetsMm = [];
|
|
360
|
+
pages.forEach(({ sheet: index, goal }, page) => {
|
|
361
|
+
const sheet = prepared[index];
|
|
362
|
+
const board = measured[page];
|
|
363
|
+
// Page n holds the nth board, unless an instruction pushed a board onto
|
|
364
|
+
// the next page.
|
|
365
|
+
const landed = board !== undefined && board.boardPage === page + 1;
|
|
366
|
+
if (goal) {
|
|
367
|
+
offsetsMm.push(checked(sheet.code, () => {
|
|
368
|
+
const start = measured[page - 1];
|
|
369
|
+
const offset = landed && start !== undefined
|
|
370
|
+
? start.boardTopMm + offsetsMm[page - 1] - board.boardTopMm
|
|
371
|
+
: -1;
|
|
372
|
+
if (offset < 0) {
|
|
373
|
+
throw new Error(`${sheet.code}: the goal page's board doesn't land at the start's height`);
|
|
374
|
+
}
|
|
375
|
+
return offset;
|
|
376
|
+
}));
|
|
377
|
+
return;
|
|
311
378
|
}
|
|
312
|
-
|
|
313
|
-
|
|
379
|
+
offsetsMm.push(checked(sheet.code, () => {
|
|
380
|
+
const room = board === undefined
|
|
381
|
+
? -1
|
|
382
|
+
: sheet.areaBottom - board.boardTopMm - sheet.drawing.height;
|
|
383
|
+
if (!landed || room < 0) {
|
|
384
|
+
throw new Error(`The instruction (${sheet.instruction.length} characters) is too long for a board this tall`);
|
|
385
|
+
}
|
|
386
|
+
return room / 2;
|
|
387
|
+
}));
|
|
388
|
+
});
|
|
314
389
|
const created = configuredPdfmake().createPdf(definition(prepared, offsetsMm, title, []));
|
|
315
390
|
const doc = (await created.getStream());
|
|
316
391
|
// Ask viewers not to scale the page. PDFKit 0.20 ends the ViewerPreferences
|
|
@@ -320,13 +395,14 @@ async function render(sheets, title, named) {
|
|
|
320
395
|
root.ViewerPreferences.data.PrintScaling = "None";
|
|
321
396
|
return await created.getBuffer();
|
|
322
397
|
}
|
|
323
|
-
/** One instance's sheet as a one
|
|
398
|
+
/** One instance's sheet as a PDF: one page, or two for a Rearrange the Pieces board, its start and its goal. */
|
|
324
399
|
export async function renderSheet(options) {
|
|
325
400
|
return await render([options], options.code, false);
|
|
326
401
|
}
|
|
327
402
|
/**
|
|
328
403
|
* Several instances' sheets in one PDF, in the order given: each on a page
|
|
329
|
-
* of its own,
|
|
404
|
+
* of its own, two for a Rearrange the Pieces board, exactly as it prints
|
|
405
|
+
* alone, turned its own way. A sheet that
|
|
330
406
|
* can't print fails the whole with a `SheetError` naming it; an empty list
|
|
331
407
|
* is an error rather than an empty PDF.
|
|
332
408
|
*/
|
package/sheet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","sourceRoot":"","sources":["src/sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,E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AAC,CAAC;IACvC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAElD,OAAO,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC;AACnC,CAAC;AAED,gHAAgH;AAChH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAqB;IACrD,OAAO,MAAM,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA+B,EAC/B,EAAE,KAAK,KAAsB,EAAE;IAE/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,MAAM,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|
package/src/limits.ts
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
isLinks,
|
|
12
12
|
isMirror,
|
|
13
13
|
isPlaced,
|
|
14
|
+
isSeek,
|
|
15
|
+
seekFootprint,
|
|
14
16
|
} from "@cogniplay/logic-games";
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -122,9 +124,9 @@ export function gridsAcross(
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/**
|
|
125
|
-
* What a board takes on a sheet, in millimetres. For Amoeba
|
|
126
|
-
* that is the board:
|
|
127
|
-
* targets lie on it. For Line Counts: its cells, a cell more across when any row has a
|
|
127
|
+
* What a board takes on a sheet, in millimetres. For Amoeba, No Way Back and
|
|
128
|
+
* Rearrange the Pieces that is the board: their pieces start on it, and the
|
|
129
|
+
* targets lie on it; a Rearrange the Pieces goal page has the same box. For Line Counts: its cells, a cell more across when any row has a
|
|
128
130
|
* clue, a cell more down when any column has one, and two cells more down
|
|
129
131
|
* when any piece is to place. For Fair Shares: its grids in rows of
|
|
130
132
|
* `gridsAcross`, a cell between two grids across and down, and two cells
|
|
@@ -133,8 +135,11 @@ export function gridsAcross(
|
|
|
133
135
|
* Build the Mirror Image: the bounding box of the board and its image, the
|
|
134
136
|
* axis's 3 mm past both its ends, 6 mm more down for a vertical axis and
|
|
135
137
|
* across for a horizontal one, and two cells more down when any piece is to
|
|
136
|
-
* place.
|
|
137
|
-
*
|
|
138
|
+
* place. For Find the Hidden Shapes: the format's one layout, in half
|
|
139
|
+
* cells at half the cell size, `seekFootprint`: the board with its row
|
|
140
|
+
* numbers and letters, the tray of its hidden pieces and a trial search's
|
|
141
|
+
* trials. The content repository's validator and the backend's import
|
|
142
|
+
* compute the same from the data.
|
|
138
143
|
*/
|
|
139
144
|
export function footprintMm(
|
|
140
145
|
instance: GameData,
|
|
@@ -147,6 +152,13 @@ export function footprintMm(
|
|
|
147
152
|
cellSizeMm
|
|
148
153
|
);
|
|
149
154
|
}
|
|
155
|
+
if (isSeek(instance)) {
|
|
156
|
+
const { width, height } = seekFootprint(instance);
|
|
157
|
+
return {
|
|
158
|
+
width: (width * cellSizeMm) / 2,
|
|
159
|
+
height: (height * cellSizeMm) / 2,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
150
162
|
if (isMirror(instance)) {
|
|
151
163
|
const grids = gridsSizeMm(instance, cellSizeMm);
|
|
152
164
|
const ends = axisEndsMm;
|
package/src/sheet.ts
CHANGED
|
@@ -4,10 +4,17 @@ import {
|
|
|
4
4
|
isLineCounts,
|
|
5
5
|
isLinks,
|
|
6
6
|
isMirror,
|
|
7
|
+
isRearrange,
|
|
8
|
+
isSeek,
|
|
7
9
|
renderBoard,
|
|
10
|
+
renderGoal,
|
|
8
11
|
} from "@cogniplay/logic-games";
|
|
9
12
|
|
|
10
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
Content,
|
|
15
|
+
ContentSection,
|
|
16
|
+
TDocumentDefinitions,
|
|
17
|
+
} from "pdfmake/interfaces";
|
|
11
18
|
|
|
12
19
|
import {
|
|
13
20
|
boardLimitsMm,
|
|
@@ -52,7 +59,7 @@ const instructionGapMm = 3;
|
|
|
52
59
|
/** The renderer's margin around the cells for the heavy outline, which may lie in the page margin. */
|
|
53
60
|
const outlinePaddingMm = 1;
|
|
54
61
|
|
|
55
|
-
/** What a layout pass reports: the page
|
|
62
|
+
/** What a layout pass reports for each board drawn: the page it landed on, and where its top is. */
|
|
56
63
|
interface Measured {
|
|
57
64
|
boardPage: number;
|
|
58
65
|
boardTopMm: number;
|
|
@@ -109,6 +116,11 @@ interface Prepared {
|
|
|
109
116
|
label: string;
|
|
110
117
|
svg: string;
|
|
111
118
|
drawing: { width: number; height: number };
|
|
119
|
+
/**
|
|
120
|
+
* A Rearrange the Pieces board's goal page: its heading, and the goal
|
|
121
|
+
* picture, the start's size. None for the other games.
|
|
122
|
+
*/
|
|
123
|
+
goal: { heading: string; svg: string } | undefined;
|
|
112
124
|
pageSize: (typeof pageSizes)[keyof typeof pageSizes];
|
|
113
125
|
orientation: "portrait" | "landscape";
|
|
114
126
|
pageWidth: number;
|
|
@@ -134,7 +146,7 @@ function prepare(options: SheetOptions): Prepared {
|
|
|
134
146
|
if (colour !== "colour" && colour !== "greyscale") {
|
|
135
147
|
throw new Error(`Unknown colour "${String(colour)}": colour or greyscale`);
|
|
136
148
|
}
|
|
137
|
-
const { label } = known(wording, language, "language");
|
|
149
|
+
const { label, goal: goalHeading } = known(wording, language, "language");
|
|
138
150
|
|
|
139
151
|
const size = boardSizeMm(instance, cellSizeMm);
|
|
140
152
|
// What the board takes with its clues and its pieces to place; for Amoeba,
|
|
@@ -146,13 +158,20 @@ function prepare(options: SheetOptions): Prepared {
|
|
|
146
158
|
const taken =
|
|
147
159
|
footprint.width === size.width && footprint.height === size.height
|
|
148
160
|
? ""
|
|
149
|
-
:
|
|
150
|
-
? `, ${footprint.width}×${footprint.height} mm with its
|
|
151
|
-
(instance.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
: isSeek(instance)
|
|
162
|
+
? `, ${footprint.width}×${footprint.height} mm with its addresses` +
|
|
163
|
+
(instance.search.kind === "trial" &&
|
|
164
|
+
instance.search.questions.length > 0
|
|
165
|
+
? `, the pieces and ${instance.search.questions.length} ` +
|
|
166
|
+
(instance.search.questions.length === 1 ? "trial," : "trials,")
|
|
167
|
+
: " and the pieces,")
|
|
168
|
+
: isMirror(instance)
|
|
169
|
+
? `, ${footprint.width}×${footprint.height} mm with its image, ` +
|
|
170
|
+
(instance.transform.kind === "half-turn"
|
|
171
|
+
? ""
|
|
172
|
+
: "the axis's 3 mm past both ends, ") +
|
|
173
|
+
"and the pieces to place,"
|
|
174
|
+
: `, ${footprint.width}×${footprint.height} mm with its clues and pieces,`;
|
|
156
175
|
const what = isFairShares(instance)
|
|
157
176
|
? `${instance.shares} grids of ${size.width}×${size.height} mm, ` +
|
|
158
177
|
`${footprint.width}×${footprint.height} mm with the pieces to share, fit`
|
|
@@ -179,19 +198,28 @@ function prepare(options: SheetOptions): Prepared {
|
|
|
179
198
|
// and a Build the Mirror Image board as Fill the Shape's, with its
|
|
180
199
|
// pattern's grid, its pattern and its axis beside it. A No Way Back board
|
|
181
200
|
// prints its start: the pieces as ghosts with their letters, the targets
|
|
182
|
-
// dashed, no X.
|
|
183
|
-
|
|
201
|
+
// dashed, no X. A Rearrange the Pieces board prints its start as No Way
|
|
202
|
+
// Back's, and on a second page its goal picture, the start's size. A Find
|
|
203
|
+
// the Hidden Shapes board prints its start in its own one layout: the
|
|
204
|
+
// board with its addresses and marks, the hidden pieces at half scale
|
|
205
|
+
// under it and the trials at half size, the footprint exactly, whatever
|
|
206
|
+
// the tray's options say.
|
|
207
|
+
const renderOptions = {
|
|
184
208
|
cellSizeMm,
|
|
185
209
|
marks,
|
|
186
|
-
pieceStyle: "ghost",
|
|
210
|
+
pieceStyle: "ghost" as const,
|
|
187
211
|
pieceColours: colour === "colour" ? pieceColours : undefined,
|
|
188
212
|
trayScale: 0.5,
|
|
189
213
|
trayWidthMm: limit.width,
|
|
190
214
|
...(isFairShares(instance)
|
|
191
215
|
? { gridsPerRow: gridsAcross(instance, cellSizeMm) }
|
|
192
216
|
: {}),
|
|
193
|
-
}
|
|
217
|
+
};
|
|
218
|
+
const svg = renderBoard(instance, renderOptions);
|
|
194
219
|
const drawing = drawingSizeMm(svg);
|
|
220
|
+
const goal = isRearrange(instance)
|
|
221
|
+
? { heading: goalHeading, svg: renderGoal(instance, renderOptions) }
|
|
222
|
+
: undefined;
|
|
195
223
|
|
|
196
224
|
// The limits count cells, but a piece or a mark off the board, or pieces to
|
|
197
225
|
// place that need a second row, make the drawing larger than the count; it
|
|
@@ -227,6 +255,7 @@ function prepare(options: SheetOptions): Prepared {
|
|
|
227
255
|
label,
|
|
228
256
|
svg,
|
|
229
257
|
drawing,
|
|
258
|
+
goal,
|
|
230
259
|
pageSize,
|
|
231
260
|
orientation,
|
|
232
261
|
pageWidth,
|
|
@@ -244,10 +273,10 @@ function prepare(options: SheetOptions): Prepared {
|
|
|
244
273
|
* instance's page in the corner. The board is pushed down by the offset.
|
|
245
274
|
*/
|
|
246
275
|
function section(sheet: Prepared, offsetMm: number): ContentSection {
|
|
247
|
-
const {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
276
|
+
const { instruction, title, svg, drawing } = sheet;
|
|
277
|
+
return page(
|
|
278
|
+
sheet,
|
|
279
|
+
[
|
|
251
280
|
{ text: instruction },
|
|
252
281
|
{
|
|
253
282
|
svg,
|
|
@@ -256,6 +285,49 @@ function section(sheet: Prepared, offsetMm: number): ContentSection {
|
|
|
256
285
|
alignment: "center",
|
|
257
286
|
margin: [0, mm(instructionGapMm + offsetMm), 0, 0],
|
|
258
287
|
},
|
|
288
|
+
],
|
|
289
|
+
title
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* A Rearrange the Pieces sheet's second page: the goal picture, the start's
|
|
295
|
+
* size, under the heading "Goal" in the header's place, where the first
|
|
296
|
+
* page has the title, so it lies outside the area the footprint measures.
|
|
297
|
+
* No instruction; the offset sets the board at the start's height. The
|
|
298
|
+
* footer is the first page's.
|
|
299
|
+
*/
|
|
300
|
+
function goalSection(
|
|
301
|
+
sheet: Prepared,
|
|
302
|
+
goal: { heading: string; svg: string },
|
|
303
|
+
offsetMm: number
|
|
304
|
+
): ContentSection {
|
|
305
|
+
const { drawing } = sheet;
|
|
306
|
+
return page(
|
|
307
|
+
sheet,
|
|
308
|
+
[
|
|
309
|
+
{
|
|
310
|
+
svg: goal.svg,
|
|
311
|
+
width: mm(drawing.width),
|
|
312
|
+
height: mm(drawing.height),
|
|
313
|
+
alignment: "center",
|
|
314
|
+
margin: [0, mm(offsetMm), 0, 0],
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
goal.heading
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** A page of a sheet: what it flows, its header's text if any, and the sheet's footer. */
|
|
322
|
+
function page(
|
|
323
|
+
sheet: Prepared,
|
|
324
|
+
flow: Content[],
|
|
325
|
+
heading: string | undefined
|
|
326
|
+
): ContentSection {
|
|
327
|
+
const { code, link, label, pageWidth } = sheet;
|
|
328
|
+
return {
|
|
329
|
+
section: [
|
|
330
|
+
...flow,
|
|
259
331
|
...(link === undefined
|
|
260
332
|
? []
|
|
261
333
|
: [
|
|
@@ -274,13 +346,13 @@ function section(sheet: Prepared, offsetMm: number): ContentSection {
|
|
|
274
346
|
pageOrientation: sheet.orientation,
|
|
275
347
|
// The header's box is the top margin and the band; the rule is placed
|
|
276
348
|
// within it from the page's edge, the title flows from its margin.
|
|
277
|
-
...(
|
|
349
|
+
...(heading === undefined
|
|
278
350
|
? {}
|
|
279
351
|
: {
|
|
280
352
|
header: {
|
|
281
353
|
stack: [
|
|
282
354
|
{
|
|
283
|
-
text:
|
|
355
|
+
text: heading,
|
|
284
356
|
fontSize: 13,
|
|
285
357
|
alignment: "center",
|
|
286
358
|
margin: [mm(marginMm), mm(titleTopMm), mm(marginMm), 0],
|
|
@@ -318,9 +390,25 @@ function section(sheet: Prepared, offsetMm: number): ContentSection {
|
|
|
318
390
|
}
|
|
319
391
|
|
|
320
392
|
/**
|
|
321
|
-
* The
|
|
322
|
-
*
|
|
323
|
-
|
|
393
|
+
* The pages each sheet prints, in order: its start, and a Rearrange the
|
|
394
|
+
* Pieces board's goal page after it.
|
|
395
|
+
*/
|
|
396
|
+
interface Page {
|
|
397
|
+
sheet: number;
|
|
398
|
+
goal: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function pagesOf(sheets: readonly Prepared[]): Page[] {
|
|
402
|
+
return sheets.flatMap((sheet, index) => [
|
|
403
|
+
{ sheet: index, goal: false },
|
|
404
|
+
...(sheet.goal === undefined ? [] : [{ sheet: index, goal: true }]),
|
|
405
|
+
]);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* The document for the sheets' pages, each board pushed down by its page's
|
|
410
|
+
* offset, with where each board landed reported to `measured` as the layout
|
|
411
|
+
* goes, in the pages' order.
|
|
324
412
|
*/
|
|
325
413
|
function definition(
|
|
326
414
|
sheets: readonly Prepared[],
|
|
@@ -344,9 +432,13 @@ function definition(
|
|
|
344
432
|
mm(marginMm + footerMm),
|
|
345
433
|
],
|
|
346
434
|
defaultStyle: { font: fontName, fontSize: 11 },
|
|
347
|
-
content: sheets.map((sheet,
|
|
348
|
-
|
|
349
|
-
|
|
435
|
+
content: pagesOf(sheets).map(({ sheet: index, goal }, page) => {
|
|
436
|
+
const sheet = sheets[index]!;
|
|
437
|
+
const offset = offsetsMm[page] ?? 0;
|
|
438
|
+
return goal && sheet.goal !== undefined
|
|
439
|
+
? goalSection(sheet, sheet.goal, offset)
|
|
440
|
+
: section(sheet, offset);
|
|
441
|
+
}),
|
|
350
442
|
// pdfmake reports every node here with its properties, once each and in
|
|
351
443
|
// the document's order, so the boards are the nodes with an svg.
|
|
352
444
|
pageBreakBefore: (node) => {
|
|
@@ -378,7 +470,7 @@ export class SheetError extends Error {
|
|
|
378
470
|
}
|
|
379
471
|
|
|
380
472
|
/**
|
|
381
|
-
* The sheets in one PDF, a page each. A sheet that can't print fails the
|
|
473
|
+
* The sheets in one PDF, a page each, a Rearrange the Pieces board two. A sheet that can't print fails the
|
|
382
474
|
* whole; with `named`, its error becomes a `SheetError` naming it, since
|
|
383
475
|
* among many the caller can't tell which it was.
|
|
384
476
|
*/
|
|
@@ -402,35 +494,60 @@ async function render(
|
|
|
402
494
|
|
|
403
495
|
// pdfmake lays out top-down, so the sheets are laid out twice: once to
|
|
404
496
|
// measure where each board lands under its instruction, and once with each
|
|
405
|
-
// board pushed down by half the room left on its page.
|
|
497
|
+
// board pushed down by half the room left on its page. A goal page's board
|
|
498
|
+
// is pushed down to its start's height.
|
|
499
|
+
const pages = pagesOf(prepared);
|
|
406
500
|
const measured: Measured[] = [];
|
|
407
501
|
await configuredPdfmake()
|
|
408
502
|
.createPdf(
|
|
409
503
|
definition(
|
|
410
504
|
prepared,
|
|
411
|
-
|
|
505
|
+
pages.map(() => 0),
|
|
412
506
|
title,
|
|
413
507
|
measured
|
|
414
508
|
)
|
|
415
509
|
)
|
|
416
510
|
.getStream();
|
|
417
|
-
const offsetsMm =
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
511
|
+
const offsetsMm: number[] = [];
|
|
512
|
+
pages.forEach(({ sheet: index, goal }, page) => {
|
|
513
|
+
const sheet = prepared[index]!;
|
|
514
|
+
const board = measured[page];
|
|
515
|
+
// Page n holds the nth board, unless an instruction pushed a board onto
|
|
516
|
+
// the next page.
|
|
517
|
+
const landed = board !== undefined && board.boardPage === page + 1;
|
|
518
|
+
if (goal) {
|
|
519
|
+
offsetsMm.push(
|
|
520
|
+
checked(sheet.code, () => {
|
|
521
|
+
const start = measured[page - 1];
|
|
522
|
+
const offset =
|
|
523
|
+
landed && start !== undefined
|
|
524
|
+
? start.boardTopMm + offsetsMm[page - 1]! - board.boardTopMm
|
|
525
|
+
: -1;
|
|
526
|
+
if (offset < 0) {
|
|
527
|
+
throw new Error(
|
|
528
|
+
`${sheet.code}: the goal page's board doesn't land at the start's height`
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
return offset;
|
|
532
|
+
})
|
|
533
|
+
);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
offsetsMm.push(
|
|
537
|
+
checked(sheet.code, () => {
|
|
538
|
+
const room =
|
|
539
|
+
board === undefined
|
|
540
|
+
? -1
|
|
541
|
+
: sheet.areaBottom - board.boardTopMm - sheet.drawing.height;
|
|
542
|
+
if (!landed || room < 0) {
|
|
543
|
+
throw new Error(
|
|
544
|
+
`The instruction (${sheet.instruction.length} characters) is too long for a board this tall`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return room / 2;
|
|
548
|
+
})
|
|
549
|
+
);
|
|
550
|
+
});
|
|
434
551
|
|
|
435
552
|
const created = configuredPdfmake().createPdf(
|
|
436
553
|
definition(prepared, offsetsMm, title, [])
|
|
@@ -446,14 +563,15 @@ async function render(
|
|
|
446
563
|
return await created.getBuffer();
|
|
447
564
|
}
|
|
448
565
|
|
|
449
|
-
/** One instance's sheet as a one
|
|
566
|
+
/** One instance's sheet as a PDF: one page, or two for a Rearrange the Pieces board, its start and its goal. */
|
|
450
567
|
export async function renderSheet(options: SheetOptions): Promise<Uint8Array> {
|
|
451
568
|
return await render([options], options.code, false);
|
|
452
569
|
}
|
|
453
570
|
|
|
454
571
|
/**
|
|
455
572
|
* Several instances' sheets in one PDF, in the order given: each on a page
|
|
456
|
-
* of its own,
|
|
573
|
+
* of its own, two for a Rearrange the Pieces board, exactly as it prints
|
|
574
|
+
* alone, turned its own way. A sheet that
|
|
457
575
|
* can't print fails the whole with a `SheetError` naming it; an empty list
|
|
458
576
|
* is an error rather than an empty PDF.
|
|
459
577
|
*/
|
package/src/wording.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SheetLanguage } from "./types.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The sheet's fixed wording, per language: the label before the code
|
|
5
|
-
*
|
|
4
|
+
* The sheet's fixed wording, per language: the label before the code, and
|
|
5
|
+
* the heading of a Rearrange the Pieces sheet's goal page. Fixed wording
|
|
6
|
+
* stays out of the database (backend decision 6), so it lives here.
|
|
6
7
|
*/
|
|
7
|
-
export const wording: Record<SheetLanguage, { label: string }> = {
|
|
8
|
-
hu: { label: "Feladat:" },
|
|
9
|
-
en: { label: "Puzzle:" },
|
|
8
|
+
export const wording: Record<SheetLanguage, { label: string; goal: string }> = {
|
|
9
|
+
hu: { label: "Feladat:", goal: "Cél" },
|
|
10
|
+
en: { label: "Puzzle:", goal: "Goal" },
|
|
10
11
|
};
|
package/wording.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SheetLanguage } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* The sheet's fixed wording, per language: the label before the code
|
|
4
|
-
*
|
|
3
|
+
* The sheet's fixed wording, per language: the label before the code, and
|
|
4
|
+
* the heading of a Rearrange the Pieces sheet's goal page. Fixed wording
|
|
5
|
+
* stays out of the database (backend decision 6), so it lives here.
|
|
5
6
|
*/
|
|
6
7
|
export declare const wording: Record<SheetLanguage, {
|
|
7
8
|
label: string;
|
|
9
|
+
goal: string;
|
|
8
10
|
}>;
|
|
9
11
|
//# sourceMappingURL=wording.d.ts.map
|
package/wording.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wording.d.ts","sourceRoot":"","sources":["src/wording.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"wording.d.ts","sourceRoot":"","sources":["src/wording.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAG1E,CAAC"}
|
package/wording.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The sheet's fixed wording, per language: the label before the code
|
|
3
|
-
*
|
|
2
|
+
* The sheet's fixed wording, per language: the label before the code, and
|
|
3
|
+
* the heading of a Rearrange the Pieces sheet's goal page. Fixed wording
|
|
4
|
+
* stays out of the database (backend decision 6), so it lives here.
|
|
4
5
|
*/
|
|
5
6
|
export const wording = {
|
|
6
|
-
hu: { label: "Feladat:" },
|
|
7
|
-
en: { label: "Puzzle:" },
|
|
7
|
+
hu: { label: "Feladat:", goal: "Cél" },
|
|
8
|
+
en: { label: "Puzzle:", goal: "Goal" },
|
|
8
9
|
};
|
|
9
10
|
//# sourceMappingURL=wording.js.map
|
package/wording.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wording.js","sourceRoot":"","sources":["src/wording.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"wording.js","sourceRoot":"","sources":["src/wording.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAA2D;IAC7E,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;CACvC,CAAC"}
|