@altnovatrail/canvas 0.3.39 → 0.3.40

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.
Files changed (74) hide show
  1. package/lib/core/boxes.d.ts +7 -7
  2. package/lib/core/boxes.js +10 -10
  3. package/lib/core/clock.d.ts +5 -5
  4. package/lib/core/clock.js +5 -5
  5. package/lib/core/crop.d.ts +13 -13
  6. package/lib/core/crop.js +10 -10
  7. package/lib/core/eraser.d.ts +6 -6
  8. package/lib/core/eraser.js +6 -6
  9. package/lib/core/example.d.ts +6 -6
  10. package/lib/core/example.js +9 -9
  11. package/lib/core/fields.d.ts +1 -1
  12. package/lib/core/fields.js +1 -1
  13. package/lib/core/geometry.d.ts +6 -5
  14. package/lib/core/geometry.js +8 -6
  15. package/lib/core/grid.d.ts +3 -3
  16. package/lib/core/grid.js +3 -3
  17. package/lib/core/groups.d.ts +14 -14
  18. package/lib/core/groups.js +6 -6
  19. package/lib/core/hands.d.ts +19 -18
  20. package/lib/core/hands.js +16 -15
  21. package/lib/core/history.d.ts +9 -9
  22. package/lib/core/history.js +6 -6
  23. package/lib/core/index.js +8 -9
  24. package/lib/core/ink.js +3 -3
  25. package/lib/core/manifest.d.ts +3 -3
  26. package/lib/core/manifest.js +6 -6
  27. package/lib/core/marks.d.ts +39 -39
  28. package/lib/core/marks.js +34 -34
  29. package/lib/core/notation.d.ts +5 -5
  30. package/lib/core/outline.d.ts +3 -3
  31. package/lib/core/outline.js +6 -6
  32. package/lib/core/page.d.ts +7 -7
  33. package/lib/core/page.js +10 -10
  34. package/lib/core/png.d.ts +3 -3
  35. package/lib/core/png.js +3 -3
  36. package/lib/core/raster.d.ts +3 -3
  37. package/lib/core/raster.js +3 -3
  38. package/lib/core/recorder.d.ts +7 -7
  39. package/lib/core/recorder.js +7 -7
  40. package/lib/core/screen.d.ts +2 -2
  41. package/lib/core/screen.js +1 -1
  42. package/lib/core/sets.d.ts +1 -1
  43. package/lib/core/sets.js +1 -1
  44. package/lib/core/sheet.d.ts +3 -3
  45. package/lib/core/sheet.js +3 -3
  46. package/lib/core/submission.d.ts +24 -24
  47. package/lib/core/submission.js +21 -21
  48. package/lib/core/task.d.ts +17 -16
  49. package/lib/core/task.js +14 -13
  50. package/lib/core/tracing.d.ts +20 -20
  51. package/lib/core/tracing.js +20 -20
  52. package/lib/core/widths.d.ts +2 -2
  53. package/lib/core/widths.js +5 -5
  54. package/lib/core/work.d.ts +18 -18
  55. package/lib/core/work.js +21 -21
  56. package/lib/core/zoom.d.ts +4 -4
  57. package/lib/core/zoom.js +4 -4
  58. package/lib/element/index.d.ts +87 -87
  59. package/lib/element/index.js +284 -281
  60. package/lib/element/labels.d.ts +17 -17
  61. package/lib/element/labels.js +7 -8
  62. package/lib/element/notation.js +1 -1
  63. package/lib/element/parts.d.ts +2 -2
  64. package/lib/element/parts.js +6 -6
  65. package/lib/element/pictures.js +1 -1
  66. package/lib/element/probe.d.ts +2 -2
  67. package/lib/element/probe.js +3 -3
  68. package/lib/element/session.js +2 -2
  69. package/lib/element/statement.d.ts +2 -2
  70. package/lib/element/statement.js +6 -6
  71. package/lib/element/tools.d.ts +17 -18
  72. package/lib/element/tools.js +30 -29
  73. package/lib/element/tracing.js +8 -8
  74. package/package.json +3 -3
@@ -2,15 +2,15 @@ import RBush from "rbush";
2
2
  import { boxOf, tenths } from "./geometry.js";
3
3
  import { Sets } from "./sets.js";
4
4
  /**
5
- * The rule the sheet groups by (R24): 2 seconds, the threshold by which studies of writing tell a
5
+ * The rule the sheet groups by: 2 seconds, the threshold by which studies of writing tell a
6
6
  * pause of writing from one of thinking, and a cell of the default grid, across and down.
7
7
  */
8
8
  export const GROUP_RULE = Object.freeze({ pause: 2000, across: 50, down: 50 });
9
9
  /**
10
- * The groups of the strokes on a sheet (R24): the strokes it shows, with the times of their points
10
+ * The groups of the strokes on a sheet: the strokes it shows, with the times of their points
11
11
  * as they were written, in any order. Erased strokes are none of it: whoever groups a history
12
12
  * replays it first, and the groups come from what the sheet shows. Labelled by place, from the top
13
- * down (R09): A, B, … Z, then AA, AB, … — by the top of a group's rectangle, then its left edge.
13
+ * down: A, B, … Z, then AA, AB, … — by the top of a group's rectangle, then its left edge.
14
14
  */
15
15
  export function groupsOf(strokes, rule = GROUP_RULE) {
16
16
  const pieces = piecesOf(strokes);
@@ -32,9 +32,9 @@ export function groupsOf(strokes, rule = GROUP_RULE) {
32
32
  .map(({ ids }, n) => ({ label: labelOf(n), ids }));
33
33
  }
34
34
  /**
35
- * The pairs of neighbours among the strokes on a sheet, by ID (R24): each pair once, the smaller
35
+ * The pairs of neighbours among the strokes on a sheet, by ID: each pair once, the smaller
36
36
  * ID first, in ascending order. Its groups join these pairs; spec's test vectors give them too, for
37
- * a runner to see where its grouping parts from the sheet's (R94 spec).
37
+ * a runner to see where its grouping parts from the sheet's.
38
38
  */
39
39
  export function neighboursOf(strokes, rule = GROUP_RULE) {
40
40
  return pairsOf(piecesOf(strokes), rule)
@@ -43,7 +43,7 @@ export function neighboursOf(strokes, rule = GROUP_RULE) {
43
43
  }
44
44
  /**
45
45
  * The rectangle of a group on the sheet: the box around the points of its strokes, in sheet units,
46
- * of the geometry it is given — the raw strokes on the device, the recorded ones in a sample (R09).
46
+ * of the geometry it is given — the raw strokes on the device, the recorded ones in a sample.
47
47
  * Its box in the fractions of a cut-out is the cut-out's.
48
48
  */
49
49
  export function rectOf(ids, strokes) {
@@ -1,8 +1,8 @@
1
1
  /**
2
- * A pointer as the hands on the sheet see it (R29): where it is on the screen, how big its contact
3
- * is, and when. The DOM-free part sees no DOM (R12), so the element hands it this much of each
2
+ * A pointer as the hands on the sheet see it: where it is on the screen, how big its contact
3
+ * is, and when (R29). The DOM-free part sees no DOM, so the element hands it this much of each
4
4
  * pointer event. The contact's size decides only what the pointer may do: it goes into no stroke,
5
- * no history and no sample (R09).
5
+ * no history and no sample.
6
6
  */
7
7
  export interface Contact {
8
8
  /** The event's `pointerId`. */
@@ -22,33 +22,34 @@ export interface Contact {
22
22
  readonly time: number;
23
23
  }
24
24
  /**
25
- * A touch wider or taller than this, in CSS pixels, is a palm (R29). WebKit on iPadOS gives a touch
25
+ * A touch wider or taller than this, in CSS pixels, is a palm. WebKit on iPadOS gives a touch
26
26
  * twice its contact's radius, a fingertip's 40–60 px by one report, so canvas-api's 30 px would
27
27
  * take most fingers there for palms. No tablet has measured it.
28
28
  */
29
29
  export declare const PALM_PX = 100;
30
30
  /**
31
- * Two touches that come down at most this many milliseconds apart are two fingers of one gesture
32
- * (R29): Android's tap timeout, 100 ms, with a margin for children's fingers.
31
+ * Two touches that come down at most this many milliseconds apart are two fingers of one gesture:
32
+ * Android's tap timeout, 100 ms, with a margin for children's fingers.
33
33
  */
34
34
  export declare const PAIR_MS = 150;
35
35
  /**
36
- * How far a touch may wander, in CSS pixels, before it is going somewhere (R29): Android's touch
36
+ * How far a touch may wander, in CSS pixels, before it is going somewhere: Android's touch
37
37
  * slop, 8 dp. A finger that has gone further is writing, and two fingers scroll once their middle
38
38
  * has gone further.
39
39
  */
40
40
  export declare const SLOP_PX = 8;
41
41
  /**
42
42
  * Two fingers that have gone this many times further along one axis than along the other, when
43
- * they pass the slop, scroll along that axis alone for the rest of the gesture (R73): a scroll
43
+ * they pass the slop, scroll along that axis alone for the rest of the gesture: a scroll
44
44
  * down a sheet does not wander sideways, nor one across it up and down. Between, they go
45
45
  * both ways.
46
46
  */
47
47
  export declare const RAIL = 2;
48
48
  /**
49
- * The pen mode (R29): on from a pen's touch on a sheet, till the page goes, with no button that
50
- * turns it off: while it is on, a finger neither writes nor erases, and moves the sheet (R84). One is shared by every sheet of a page, and
51
- * it lives in memory alone: nothing is stored or sent, and a new page starts without it.
49
+ * The pen mode: on from a pen's touch on a sheet, till the page goes, with no button that
50
+ * turns it off: while it is on, a finger neither writes nor erases, and moves the sheet. One is
51
+ * shared by every sheet of a page, and it lives in memory alone: nothing is stored or sent, and a
52
+ * new page starts without it.
52
53
  *
53
54
  * It knows, too, whether any sheet of the page is written on, and tells its sheets when the last
54
55
  * stroke ends: each bar shows the mode as it is then.
@@ -83,11 +84,11 @@ export interface HandsSheet {
83
84
  scroll(dx: number, dy: number, fresh: boolean): void;
84
85
  /**
85
86
  * Two fingers drew apart, or together, by `ratio` of the span between them: the sheet's zoom
86
- * goes by it, the point of the sheet at `x` and `y` on the screen, their middle, standing (R73).
87
+ * goes by it, the point of the sheet at `x` and `y` on the screen, their middle, standing.
87
88
  */
88
89
  zoom(ratio: number, x: number, y: number): void;
89
90
  /**
90
- * Whether the sheet scrolls across at all now: one wider than its container does (R73). A
91
+ * Whether the sheet scrolls across at all now: one wider than its container does. A
91
92
  * gesture on a sheet that does not goes by its travel down alone.
92
93
  */
93
94
  across(): boolean;
@@ -96,16 +97,16 @@ export interface HandsSheet {
96
97
  * What a pointer down on the sheet does:
97
98
  * - "writes": it may write or erase, and does while the sheet says it is the writer;
98
99
  * - "waits": a finger in pen mode, waiting for a second to scroll with, or to go past the slop
99
- * and drag the sheet alone (R84);
100
+ * and drag the sheet alone;
100
101
  * - "scrolls": the finger that drags the sheet, or one of the two fingers of a gesture;
101
102
  * - "palm": too big for a finger, it does nothing until it lifts;
102
103
  * - "idle": it does nothing until it lifts.
103
104
  */
104
105
  export type Role = "writes" | "waits" | "scrolls" | "palm" | "idle";
105
106
  /**
106
- * The hands on a sheet (R29): which pointer may write, which is a palm, and which two fingers
107
+ * The hands on a sheet: which pointer may write, which is a palm, and which two fingers
107
108
  * scroll, for a pen, fingers and a mouse on one screen.
108
- * - One pointer writes at a time (R18), and the sheet's recorder and eraser say which.
109
+ * - One pointer writes at a time, and the sheet's recorder and eraser say which.
109
110
  * - A pen's touch puts the page in pen mode and takes away the stroke of a touch under way: it was
110
111
  * a palm. While a pen or a mouse writes, a touch does nothing until it lifts.
111
112
  * - A touch wider or taller than `PALM_PX`, at its `pointerdown` or at any move, is a palm: it does
@@ -115,13 +116,13 @@ export type Role = "writes" | "waits" | "scrolls" | "palm" | "idle";
115
116
  * comes later does nothing.
116
117
  * - In pen mode a finger writes nothing, and two that come down within `PAIR_MS` scroll. One that
117
118
  * goes further than `SLOP_PX` alone, before a second comes, drags the sheet: the second does
118
- * nothing then (R84; R90 spec).
119
+ * nothing then.
119
120
  * - A third finger does nothing. When one of the two lifts, the other does nothing until it lifts.
120
121
  * - Two fingers scroll by the travel of their middle on the screen, and one by its own, past its
121
122
  * first `SLOP_PX`: along one axis alone if it went `RAIL` times further along it than along the
122
123
  * other, or else both.
123
124
  * - Two fingers whose span has changed by more than `SLOP_PX` pinch too: the zoom goes by the
124
- * span's ratio from there, about their middle (R73).
125
+ * span's ratio from there, about their middle.
125
126
  * - Any other pointer, a mouse or one of no type, writes when nothing does, whatever the mode.
126
127
  */
127
128
  export declare class Hands {
package/lib/core/hands.js CHANGED
@@ -1,31 +1,32 @@
1
1
  /**
2
- * A touch wider or taller than this, in CSS pixels, is a palm (R29). WebKit on iPadOS gives a touch
2
+ * A touch wider or taller than this, in CSS pixels, is a palm. WebKit on iPadOS gives a touch
3
3
  * twice its contact's radius, a fingertip's 40–60 px by one report, so canvas-api's 30 px would
4
4
  * take most fingers there for palms. No tablet has measured it.
5
5
  */
6
6
  export const PALM_PX = 100;
7
7
  /**
8
- * Two touches that come down at most this many milliseconds apart are two fingers of one gesture
9
- * (R29): Android's tap timeout, 100 ms, with a margin for children's fingers.
8
+ * Two touches that come down at most this many milliseconds apart are two fingers of one gesture:
9
+ * Android's tap timeout, 100 ms, with a margin for children's fingers.
10
10
  */
11
11
  export const PAIR_MS = 150;
12
12
  /**
13
- * How far a touch may wander, in CSS pixels, before it is going somewhere (R29): Android's touch
13
+ * How far a touch may wander, in CSS pixels, before it is going somewhere: Android's touch
14
14
  * slop, 8 dp. A finger that has gone further is writing, and two fingers scroll once their middle
15
15
  * has gone further.
16
16
  */
17
17
  export const SLOP_PX = 8;
18
18
  /**
19
19
  * Two fingers that have gone this many times further along one axis than along the other, when
20
- * they pass the slop, scroll along that axis alone for the rest of the gesture (R73): a scroll
20
+ * they pass the slop, scroll along that axis alone for the rest of the gesture: a scroll
21
21
  * down a sheet does not wander sideways, nor one across it up and down. Between, they go
22
22
  * both ways.
23
23
  */
24
24
  export const RAIL = 2;
25
25
  /**
26
- * The pen mode (R29): on from a pen's touch on a sheet, till the page goes, with no button that
27
- * turns it off: while it is on, a finger neither writes nor erases, and moves the sheet (R84). One is shared by every sheet of a page, and
28
- * it lives in memory alone: nothing is stored or sent, and a new page starts without it.
26
+ * The pen mode: on from a pen's touch on a sheet, till the page goes, with no button that
27
+ * turns it off: while it is on, a finger neither writes nor erases, and moves the sheet. One is
28
+ * shared by every sheet of a page, and it lives in memory alone: nothing is stored or sent, and a
29
+ * new page starts without it.
29
30
  *
30
31
  * It knows, too, whether any sheet of the page is written on, and tells its sheets when the last
31
32
  * stroke ends: each bar shows the mode as it is then.
@@ -79,9 +80,9 @@ export class PenMode {
79
80
  }
80
81
  }
81
82
  /**
82
- * The hands on a sheet (R29): which pointer may write, which is a palm, and which two fingers
83
+ * The hands on a sheet: which pointer may write, which is a palm, and which two fingers
83
84
  * scroll, for a pen, fingers and a mouse on one screen.
84
- * - One pointer writes at a time (R18), and the sheet's recorder and eraser say which.
85
+ * - One pointer writes at a time, and the sheet's recorder and eraser say which.
85
86
  * - A pen's touch puts the page in pen mode and takes away the stroke of a touch under way: it was
86
87
  * a palm. While a pen or a mouse writes, a touch does nothing until it lifts.
87
88
  * - A touch wider or taller than `PALM_PX`, at its `pointerdown` or at any move, is a palm: it does
@@ -91,13 +92,13 @@ export class PenMode {
91
92
  * comes later does nothing.
92
93
  * - In pen mode a finger writes nothing, and two that come down within `PAIR_MS` scroll. One that
93
94
  * goes further than `SLOP_PX` alone, before a second comes, drags the sheet: the second does
94
- * nothing then (R84; R90 spec).
95
+ * nothing then.
95
96
  * - A third finger does nothing. When one of the two lifts, the other does nothing until it lifts.
96
97
  * - Two fingers scroll by the travel of their middle on the screen, and one by its own, past its
97
98
  * first `SLOP_PX`: along one axis alone if it went `RAIL` times further along it than along the
98
99
  * other, or else both.
99
100
  * - Two fingers whose span has changed by more than `SLOP_PX` pinch too: the zoom goes by the
100
- * span's ratio from there, about their middle (R73).
101
+ * span's ratio from there, about their middle.
101
102
  * - Any other pointer, a mouse or one of no type, writes when nothing does, whatever the mode.
102
103
  */
103
104
  export class Hands {
@@ -148,7 +149,7 @@ export class Hands {
148
149
  hand.x = contact.x;
149
150
  hand.y = contact.y;
150
151
  hand.travel = Math.max(hand.travel, Math.hypot(contact.x - hand.x0, contact.y - hand.y0));
151
- // A finger of pen mode that has gone past the slop with no second drags the sheet alone (R84),
152
+ // A finger of pen mode that has gone past the slop with no second drags the sheet alone,
152
153
  // but not while a sheet of the page is written on: nothing moves under the pen. Another finger
153
154
  // that waits then does nothing until it lifts, and takes no drag over from where it came down.
154
155
  if (hand.role === "waits" &&
@@ -333,8 +334,8 @@ export class Hands {
333
334
  this.#sheet.scroll(dx, dy, false);
334
335
  }
335
336
  /**
336
- * The two fingers' span has changed: past the slop, the zoom goes by its ratio to the last step's,
337
- * from the slop on, without a jump, about their middle (R73).
337
+ * The two fingers' span has changed: past the slop, the zoom goes by its ratio to the last
338
+ * step's, from the slop on, without a jump, about their middle.
338
339
  */
339
340
  #pinch(gesture, span, middle) {
340
341
  if (gesture.span === undefined) {
@@ -1,20 +1,20 @@
1
1
  import type { HistoryEvent } from "@altnovatrail/spec/canvas";
2
2
  import type { Stroke } from "./ink.js";
3
3
  /**
4
- * An event of the history of writing (R09, R22): spec's type, of the contract of canvas and app
5
- * (R74 spec; R07). What an action on the sheet did, at the sheet's time `t` when it landed, in the
4
+ * An event of the history of writing: spec's type, of the contract of canvas and app.
5
+ * What an action on the sheet did, at the sheet's time `t` when it landed, in the
6
6
  * order the actions landed; each event says which strokes it put on the sheet or took off, so
7
7
  * whoever reads the history replays it without the rules of the stack of undo (R19). Those the
8
- * sheet hands out are frozen through (R27).
8
+ * sheet hands out are frozen through.
9
9
  */
10
10
  export type { HistoryEvent };
11
11
  /**
12
12
  * The strokes a history leaves on the sheet, in the order they were written: what the sheet shows
13
- * after it (R09).
13
+ * after it.
14
14
  */
15
15
  export declare function replay(history: readonly HistoryEvent[]): Stroke[];
16
16
  /**
17
- * The events of a history given to the sheet (R27), each checked field by field and copied into
17
+ * The events of a history given to the sheet, each checked field by field and copied into
18
18
  * frozen objects of the sheet's own, with only the fields the sheet keeps: others are passed over.
19
19
  * A value that is not such a history is a TypeError that names the field. Each event must be one of
20
20
  * the four, at a time from 0 that never goes back along the history; a stroke must have a new ID, a
@@ -22,18 +22,18 @@ export declare function replay(history: readonly HistoryEvent[]): Stroke[];
22
22
  * times never going back and none after the time it landed. Times are checked for their order
23
23
  * alone: strokes may overlap in time, as several pointers at once would write them. On a task from
24
24
  * paper, `paper`, a stroke written on the tracing paper says so, `on: "tracing"`, its points from
25
- * the paper's top left corner within the sheet's size; anywhere else `on` is a TypeError
26
- * (R87). Whether the actions keep the rules of the stack, the work on the sheet checks as it
25
+ * the paper's top left corner within the sheet's size; anywhere else `on` is a TypeError.
26
+ * Whether the actions keep the rules of the stack, the work on the sheet checks as it
27
27
  * replays them (`Work.restore`).
28
28
  */
29
29
  export declare function historyOf(value: unknown, paper?: boolean): HistoryEvent[];
30
30
  /**
31
- * An event, frozen through: its stroke with its points, or its lists of IDs (R27). Whoever holds
31
+ * An event, frozen through: its stroke with its points, or its lists of IDs. Whoever holds
32
32
  * an event the sheet handed out cannot change the sheet by it.
33
33
  */
34
34
  export declare function frozen(event: HistoryEvent): HistoryEvent;
35
35
  /**
36
- * Whether a value given as a history is the history the sheet has (R27): the very array, or a list
36
+ * Whether a value given as a history is the history the sheet has: the very array, or a list
37
37
  * whose every event says what the sheet's says, by the fields the sheet keeps — others are passed
38
38
  * over. `undefined` is the empty history. It never throws: a value that is no history is simply not
39
39
  * the same one.
@@ -2,7 +2,7 @@ import { record, shown } from "./fields.js";
2
2
  import { REACH } from "./sheet.js";
3
3
  /**
4
4
  * The strokes a history leaves on the sheet, in the order they were written: what the sheet shows
5
- * after it (R09).
5
+ * after it.
6
6
  */
7
7
  export function replay(history) {
8
8
  const written = [];
@@ -29,7 +29,7 @@ export function replay(history) {
29
29
  return written.filter((stroke) => visible.has(stroke.id));
30
30
  }
31
31
  /**
32
- * The events of a history given to the sheet (R27), each checked field by field and copied into
32
+ * The events of a history given to the sheet, each checked field by field and copied into
33
33
  * frozen objects of the sheet's own, with only the fields the sheet keeps: others are passed over.
34
34
  * A value that is not such a history is a TypeError that names the field. Each event must be one of
35
35
  * the four, at a time from 0 that never goes back along the history; a stroke must have a new ID, a
@@ -37,8 +37,8 @@ export function replay(history) {
37
37
  * times never going back and none after the time it landed. Times are checked for their order
38
38
  * alone: strokes may overlap in time, as several pointers at once would write them. On a task from
39
39
  * paper, `paper`, a stroke written on the tracing paper says so, `on: "tracing"`, its points from
40
- * the paper's top left corner within the sheet's size; anywhere else `on` is a TypeError
41
- * (R87). Whether the actions keep the rules of the stack, the work on the sheet checks as it
40
+ * the paper's top left corner within the sheet's size; anywhere else `on` is a TypeError.
41
+ * Whether the actions keep the rules of the stack, the work on the sheet checks as it
42
42
  * replays them (`Work.restore`).
43
43
  */
44
44
  export function historyOf(value, paper = false) {
@@ -90,7 +90,7 @@ export function historyOf(value, paper = false) {
90
90
  });
91
91
  }
92
92
  /**
93
- * An event, frozen through: its stroke with its points, or its lists of IDs (R27). Whoever holds
93
+ * An event, frozen through: its stroke with its points, or its lists of IDs. Whoever holds
94
94
  * an event the sheet handed out cannot change the sheet by it.
95
95
  */
96
96
  export function frozen(event) {
@@ -110,7 +110,7 @@ export function frozen(event) {
110
110
  return Object.freeze(event);
111
111
  }
112
112
  /**
113
- * Whether a value given as a history is the history the sheet has (R27): the very array, or a list
113
+ * Whether a value given as a history is the history the sheet has: the very array, or a list
114
114
  * whose every event says what the sheet's says, by the fields the sheet keeps — others are passed
115
115
  * over. `undefined` is the empty history. It never throws: a value that is no history is simply not
116
116
  * the same one.
package/lib/core/index.js CHANGED
@@ -1,15 +1,14 @@
1
1
  // The DOM-free part of the canvas, the package's entry point @altnovatrail/canvas/core: plain
2
2
  // TypeScript that runs the same in a browser and in Node, for the tests and the synthetic samples
3
- // too (R05, R07). Importing it registers no element: the element is the other entry point. It
3
+ // too. Importing it registers no element: the element is the other entry point. It
4
4
  // gives the sheet's size, the types of the data the element takes and gives — the strokes and the
5
5
  // history of writing, the task, the worked example and the manifest, how far the learner has gone
6
- // through the example's demo (R42) and the context of a submission, of a sheet, a workbook or a
7
- // task from paper with where its tracing paper lay (R87), all of spec's types (R73 spec, R74
8
- // spec), and the tutor's marks, spec's types too (R83 spec) — and the fold of a history into the
9
- // strokes it leaves, so that a consumer reads a history it keeps without the DOM (R27). The code runs without the DOM, but spec's
10
- // declarations of the element's contract, which its types come from, name the DOM's types too: a
11
- // consumer without the DOM's types skips them with skipLibCheck (R27). The rules of the groups, the
12
- // crop and the snapping stay inside: the eval protocol has taken them as they are, and spec's test
13
- // vectors pin them (R94 spec).
6
+ // through the example's demo and the context of a submission, of a sheet, a workbook or a
7
+ // task from paper with where its tracing paper lay, all of spec's types, and the tutor's marks,
8
+ // spec's types too — and the fold of a history into the strokes it leaves, so that a consumer reads
9
+ // a history it keeps without the DOM. The code runs without the DOM, but spec's declarations of the
10
+ // element's contract, which its types come from, name the DOM's types too: a consumer without the
11
+ // DOM's types skips them with skipLibCheck. The rules of the groups, the crop and the snapping stay
12
+ // inside: the eval protocol has taken them as they are, and spec's test vectors pin them.
14
13
  export { replay } from "./history.js";
15
14
  export { SHEET } from "./sheet.js";
package/lib/core/ink.js CHANGED
@@ -1,5 +1,5 @@
1
- // A point of a stroke and a stroke (R06, R09, R18, R27): spec's types, of the contract of canvas
2
- // and app (R74 spec; R07) — where a point lies on the sheet, in logical units, when it was written
1
+ // A point of a stroke and a stroke: spec's types, of the contract of canvas
2
+ // and app — where a point lies on the sheet, in logical units, when it was written
3
3
  // and how hard the pointer pressed, and a stroke's ID on its sheet, its pointer's type and its
4
- // points. Only a pen's pressure changes the width of the line (R05, R18).
4
+ // points. Only a pen's pressure changes the width of the line (R05).
5
5
  export {};
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * The version of the module format the element reads: while the format is v0, the platform reads
3
- * its current version alone, and a module of another is refused with the reason (R44 spec). The
4
- * format's rules of a module's versions are module-kit's and api's: the element compares none (R32).
3
+ * its current version alone, and a module of another is refused with the reason. The
4
+ * format's rules of a module's versions are module-kit's and api's: the element compares none.
5
5
  */
6
6
  export declare const FORMAT = "0.4";
7
- /** The open view of a module's manifest, whole: spec's type (R73 spec). */
7
+ /** The open view of a module's manifest, whole: spec's type. */
8
8
  export type { Manifest } from "@altnovatrail/spec/formatv0/open";
9
9
  /**
10
10
  * What the element makes of a manifest: the height of a digit its crop for checking is drawn at,
@@ -1,17 +1,17 @@
1
- // The module's manifest as the element reads it (R32): the open view of manifest.yaml, of which it
1
+ // The module's manifest as the element reads it: the open view of manifest.yaml, of which it
2
2
  // takes three fields — the version of the module format, the height of a digit on the crop for
3
- // checking and the explanation language, which the task's statement is in (R51 spec). The rest of
3
+ // checking and the explanation language, which the task's statement is in. The rest of
4
4
  // the manifest it passes over: what a manifest may hold, module-kit checks. Its canvas settings are
5
5
  // the canvas's own, though: a setting the element does not know is a TypeError, as a field of a
6
6
  // task is, for the element would draw the module's canvas without it. The type is spec's, from
7
- // its npm package at the version of the spec/ submodule (R73 spec; R41), and app gets the
8
- // manifest's open view once for a module's package and gives it to the element as it is (R36 spec).
7
+ // its npm package at the version of the spec/ submodule, and app gets the
8
+ // manifest's open view once for a module's package and gives it to the element as it is.
9
9
  import { CROP } from "./crop.js";
10
10
  import { closed, record, shown, whole } from "./fields.js";
11
11
  /**
12
12
  * The version of the module format the element reads: while the format is v0, the platform reads
13
- * its current version alone, and a module of another is refused with the reason (R44 spec). The
14
- * format's rules of a module's versions are module-kit's and api's: the element compares none (R32).
13
+ * its current version alone, and a module of another is refused with the reason. The
14
+ * format's rules of a module's versions are module-kit's and api's: the element compares none.
15
15
  */
16
16
  export const FORMAT = "0.4";
17
17
  /** The settings without a manifest: digits of 24 px, and the element's own language. */
@@ -4,11 +4,11 @@ import { type Box } from "./geometry.js";
4
4
  import type { Group } from "./groups.js";
5
5
  import type { Stroke } from "./ink.js";
6
6
  /**
7
- * The rule that snaps a model's box to the learner's strokes (R26): the box widens on every side by
7
+ * The rule that snaps a model's box to the learner's strokes: the box widens on every side by
8
8
  * `margin` thousandths of the height its crop draws digits at, D′, and a stroke is taken if its
9
- * share of points in it, its edges too, is `share` at least, and one point at least. Both are
9
+ * share of points in it, its edges too, is `share` at least, and one point at least (R26). Both are
10
10
  * parameters of eval (C2). The rule counts in whole numbers, places on the crop as the crop's
11
- * raster has them (R25), so that whoever snaps by it takes the same strokes.
11
+ * raster has them, so that whoever snaps by it takes the same strokes.
12
12
  */
13
13
  export interface SnapRule {
14
14
  /** How far the box widens on every side, in thousandths of D′: 0 to 1000. */
@@ -20,7 +20,7 @@ export interface SnapRule {
20
20
  readonly share: readonly [above: number, below: number];
21
21
  }
22
22
  /**
23
- * The rule the sheet snaps by (R26): a quarter of a digit — 6 px at 24, a quarter of H on the
23
+ * The rule the sheet snaps by: a quarter of a digit — 6 px at 24, a quarter of H on the
24
24
  * sheet, H the height the crop scales by — and two thirds of the points. A sweep over the
25
25
  * synthetic sheets chose two thirds over the half R43 canvas-api took: as many strokes taken
26
26
  * whole, and fewer of their neighbours.
@@ -28,48 +28,48 @@ export interface SnapRule {
28
28
  export declare const SNAP_RULE: SnapRule;
29
29
  /**
30
30
  * The context of one submission, of a sheet or of a workbook, and its parts: spec's types, of the
31
- * contract of canvas and app (R74 spec; R07). A sheet's context, which the element gives with its
31
+ * contract of canvas and app. A sheet's context, which the element gives with its
32
32
  * crop and takes back with the tutor's marks, holds the crop's numbers — its `sheet_box`, the
33
33
  * frames of the groups and the whole numbers they come from — the groups of the strokes, the table
34
- * «label → stroke IDs», and the digest of it all, `digestOf` it (R27). It goes back to a sheet
34
+ * «label → stroke IDs», and the digest of it all, `digestOf` it. It goes back to a sheet
35
35
  * whose history holds its strokes: the same sheet, or one given the same history later. Each sheet
36
36
  * numbers its strokes from 1, so a sheet of other strokes with the same IDs tells it by the digest.
37
37
  * A workbook's holds the table «box → stroke IDs», each filled box by its place, in the task's
38
- * order, and the digest of its strokes and of every box of the page, `workbookDigestOf` it (R34,
39
- * R38): no numbers of the crops, for no mark on a workbook is snapped. A task from paper's holds
38
+ * order, and the digest of its strokes and of every box of the page, `workbookDigestOf` it: no
39
+ * numbers of the crops, for no mark on a workbook is snapped. A task from paper's holds
40
40
  * what a sheet's does, its strokes where they lie on the sheet, and where the tracing paper lay,
41
- * which its digest holds with the strokes written on it (R87). An answer cell has no ID:
42
- * its place names it, its item and its place among the item's cells, each from 1 (R51 spec).
41
+ * which its digest holds with the strokes written on it. An answer cell has no ID:
42
+ * its place names it, its item and its place among the item's cells, each from 1.
43
43
  *
44
44
  * The tutor's marks of one submission, with the submission's context, are spec's types too, of the
45
- * same contract (R74 spec; R83 spec): a mark is a frame, with where it is and the name a screen
45
+ * same contract: a mark is a frame, with where it is and the name a screen
46
46
  * reader gives it, in the consumer's words — the element words nothing. Where it is: a group of
47
47
  * strokes by its label, an answer cell by its place, or a box on the crop the model saw,
48
- * [ymin, xmin, ymax, xmax] in whole thousandths of its height and width, min < max (R53 spec). On a
49
- * workbook a mark stands on a cell alone (R34). On a task from paper a mark may be a verdict too, a
50
- * tick or a cross at a box alone: the box of an answer its reading gave (R162 spec).
48
+ * [ymin, xmin, ymax, xmax] in whole thousandths of its height and width, min < max. On a
49
+ * workbook a mark stands on a cell alone. On a task from paper a mark may be a verdict too, a
50
+ * tick or a cross at a box alone: the box of an answer its reading gave.
51
51
  */
52
52
  export type { Anchor, CellPlace, CropNumbers, Mark, Marks, PaperSubmission, SheetSubmission, Submission, WorkbookSubmission, };
53
53
  /**
54
- * What a task from paper's sheet tells `placesOf` and `digestOf` (R87): where its tracing paper
54
+ * What a task from paper's sheet tells `placesOf` and `digestOf`: where its tracing paper
55
55
  * lies, and which strokes were written on it.
56
56
  */
57
57
  export interface Paper {
58
58
  readonly at: readonly [number, number];
59
- /** The tracing paper's scale (R89). */
59
+ /** The tracing paper's scale. */
60
60
  readonly scale: number;
61
61
  readonly onTracing: (id: number) => boolean;
62
62
  }
63
63
  /**
64
64
  * A mark on the sheet, `{stroke_ids, snapped_box}` (C2): the strokes it holds on to, by ID in
65
65
  * ascending order, and the rectangle of their points, in units, as the model saw them. A mark of a
66
- * workbook's cell has the box of its cell too, which its frame stands round with the ink (R39). A
66
+ * workbook's cell has the box of its cell too, which its frame stands round with the ink. A
67
67
  * mark of a box the submission found empty holds no strokes, and its `box` is then the cell's own:
68
68
  * `shownOf` frames it alone. A verdict stands by the group of strokes `verdictsOf` gives it, its
69
69
  * `box` theirs, or, with none, by the answer's box laid on the sheet by the crop's `sheetBox`: the
70
- * answer may be ink on the photo of the page. `correct` says a tick or a cross (R162 spec). A wavy
70
+ * answer may be ink on the photo of the page. `correct` says a tick or a cross. A wavy
71
71
  * line holds on to the strokes its box takes, as a frame does, and with none stands under the box
72
- * laid on the sheet, the place of the mistake; `wavy` says it is one (R87).
72
+ * laid on the sheet, the place of the mistake; `wavy` says it is one.
73
73
  */
74
74
  export interface Placed {
75
75
  readonly ids: readonly number[];
@@ -79,17 +79,17 @@ export interface Placed {
79
79
  readonly wavy?: true;
80
80
  }
81
81
  /**
82
- * The tutor's marks a value gives, checked (R26). A value that is not the marks of a submission is
82
+ * The tutor's marks a value gives, checked. A value that is not the marks of a submission is
83
83
  * a TypeError that names the field; fields the sheet does not read are passed over. The context's
84
- * keys tell its kind (R38): a sheet's crop and groups, or a workbook's boxes. The crop's
84
+ * keys tell its kind: a sheet's crop and groups, or a workbook's boxes. The crop's
85
85
  * `sheet_box` must be the one its whole numbers give, to a millionth of a unit, its frames the
86
86
  * groups', in their order, a group's label must be one of the submission's, and the digest 16 hex
87
87
  * digits. A workbook's rows name each box once and each stroke in one box, and its marks stand on
88
- * cells alone (R39). Whether the submission is this sheet's, its strokes tell (`placesOf`).
88
+ * cells alone. Whether the submission is this sheet's, its strokes tell (`placesOf`).
89
89
  */
90
90
  export declare function marksOf(value: unknown): Marks;
91
91
  /**
92
- * The strokes a model's box takes (R26), by ID in ascending order: of the strokes given, those with
92
+ * The strokes a model's box takes, by ID in ascending order: of the strokes given, those with
93
93
  * the rule's share of their points, and one at least, in the box widened by the rule's margin. The
94
94
  * box is in thousandths of the crop the model saw, and a point counts where it lies on that crop:
95
95
  * the same as the box laid on the sheet by the crop's `sheet_box` and widened there by H × margin /
@@ -98,55 +98,55 @@ export declare function marksOf(value: unknown): Marks;
98
98
  */
99
99
  export declare function snapOf(box: readonly [number, number, number, number], crop: CropNumbers, strokes: readonly Stroke[], rule?: SnapRule): number[];
100
100
  /**
101
- * Where each mark of a submission is on the sheet (R26): the strokes it holds on to, or null for a
102
- * mark that has none — the question is asked without it (R43 canvas-api). `known` is every stroke
101
+ * Where each mark of a submission is on the sheet: the strokes it holds on to, or null for a
102
+ * mark that has none — the question is asked without it. `known` is every stroke
103
103
  * the sheet has known, erased or not, as its history wrote them: a mark holds on to the strokes the
104
104
  * model saw, and shows those of them the sheet shows at the time (C2). A stroke written after the
105
105
  * submission is in none of its groups, and no mark takes it. A group's mark holds its strokes, a
106
106
  * box's the strokes it snaps to; an answer cell's holds none on a sheet, which takes no zones.
107
107
  * `cells` are the boxes of a workbook's page, in the task's order, and null on a sheet: there a
108
108
  * cell's mark holds the strokes of its row of the table, with its box; one of a box not in the
109
- * table, an empty one, holds its box alone, and one of a box not on the page holds none (R39;
110
- * R74 spec). A verdict of a task from paper always has its place, its box on the sheet (R162 spec).
109
+ * table, an empty one, holds its box alone, and one of a box not on the page holds none. A verdict
110
+ * of a task from paper always has its place, its box on the sheet.
111
111
  *
112
112
  * A submission of other strokes is a TypeError: a stroke of its groups the sheet does not know, or
113
- * a digest the sheet's strokes of those IDs do not give with the submission's numbers (R27). A
113
+ * a digest the sheet's strokes of those IDs do not give with the submission's numbers. A
114
114
  * sheet of other strokes would have those IDs too — each numbers its strokes from 1 — and a
115
115
  * context changed since the sheet gave it would place the marks by other numbers. The sheet's own
116
116
  * submission always passes, the strokes erased since too, and so does the same history given to
117
117
  * another sheet. A workbook's digest holds every box of its page too, so a page of another layout
118
- * is not its submission's (R38), and a context of the other kind of canvas is a TypeError.
118
+ * is not its submission's, and a context of the other kind of canvas is a TypeError.
119
119
  * On a task from paper, `paper`, `known` are the strokes where they lie on the sheet now, and a
120
- * context of the tracing paper at another place is a TypeError: its strokes lie elsewhere (R87).
120
+ * context of the tracing paper at another place is a TypeError: its strokes lie elsewhere.
121
121
  */
122
122
  export declare function placesOf(marks: Marks, known: readonly Stroke[], cells?: readonly Cell[] | null, rule?: SnapRule, paper?: Paper): (Placed | null)[];
123
123
  /**
124
- * The rectangle a mark shows now (R26): around the points of those of its strokes the sheet shows,
124
+ * The rectangle a mark shows now: around the points of those of its strokes the sheet shows,
125
125
  * in units, or null while it shows none of them. A mark of a box that was empty shows the box
126
- * itself, always (R39), a verdict its box, and a wavy line of no strokes its box (R162 spec).
126
+ * itself, always, a verdict its box, and a wavy line of no strokes its box.
127
127
  * `shown` gives the box of a stroke's points by its ID while the stroke is
128
- * on the screen — not erased, nor under the eraser under way (R22). New strokes are none of a
128
+ * on the screen — not erased, nor under the eraser under way. New strokes are none of a
129
129
  * mark's.
130
130
  */
131
131
  export declare function shownOf(placed: Placed, shown: (id: number) => Box | undefined): Box | null;
132
132
  /**
133
- * The digest of a submission (R27): what it was made of, in 16 hex digits — the CRC-32 and then the
134
- * Adler-32 of PNG and zlib (png.ts) of a text that holds its strokes, by ID ascending, each with its
135
- * points in tenths of a unit and whole milliseconds, as the rules see them (R24, R25), and its whole
133
+ * The digest of a submission: what it was made of, in 16 hex digits — the CRC-32 and then the
134
+ * Adler-32 of PNG and zlib (png.ts) of a text that holds its strokes, by ID ascending, each with
135
+ * its points in tenths of a unit and whole milliseconds, as the rules see them, and its whole
136
136
  * numbers: D′, the crop's size and margins, the box and the median it comes from, the groups and
137
137
  * their frames. `sheet_box` is not in it: it comes from those numbers, and is checked against them
138
138
  * within its slack. The same strokes and numbers give the same digest in every engine, through any
139
139
  * store that keeps them as JSON does. The digest tells an accidental difference, not a forged one:
140
140
  * CRC-32 tells every change within 32 bits running, and any other change keeps both sums with a
141
141
  * chance of about one in 2^32 at most. A task from paper's, `paper`, holds a last line: where the
142
- * tracing paper lies, in tenths, and the IDs of the strokes written on it, ascending (R87).
142
+ * tracing paper lies, in tenths, and the IDs of the strokes written on it, ascending.
143
143
  */
144
144
  export declare function digestOf(strokes: readonly Stroke[], crop: Pick<CropNumbers, "drawn" | "width" | "height" | "margins" | "frames" | "exact">, groups: readonly Group[], paper?: Paper): string;
145
145
  /**
146
- * The digest of a workbook's submission (R38), as `digestOf` makes a sheet's: of a text that holds
146
+ * The digest of a workbook's submission, as `digestOf` makes a sheet's: of a text that holds
147
147
  * the strokes of its table, by ID ascending, as a sheet's digest has them, then every box of the
148
148
  * page, `cells` in the task's order, with its item, its slot and its rectangle in whole page units,
149
149
  * and then the table's rows. A context of another layout gives another digest even where its
150
- * filled boxes stand where they stood (R34).
150
+ * filled boxes stand where they stood.
151
151
  */
152
152
  export declare function workbookDigestOf(strokes: readonly Stroke[], boxes: readonly Filling[], cells: readonly Cell[]): string;