@altnovatrail/canvas 0.3.38 → 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 (79) 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 +24 -16
  20. package/lib/core/hands.js +66 -14
  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 +29 -0
  30. package/lib/core/notation.js +180 -0
  31. package/lib/core/outline.d.ts +3 -3
  32. package/lib/core/outline.js +6 -6
  33. package/lib/core/page.d.ts +7 -7
  34. package/lib/core/page.js +10 -10
  35. package/lib/core/png.d.ts +3 -3
  36. package/lib/core/png.js +3 -3
  37. package/lib/core/raster.d.ts +3 -3
  38. package/lib/core/raster.js +3 -3
  39. package/lib/core/recorder.d.ts +7 -7
  40. package/lib/core/recorder.js +7 -7
  41. package/lib/core/screen.d.ts +2 -2
  42. package/lib/core/screen.js +1 -1
  43. package/lib/core/sets.d.ts +1 -1
  44. package/lib/core/sets.js +1 -1
  45. package/lib/core/sheet.d.ts +3 -3
  46. package/lib/core/sheet.js +3 -3
  47. package/lib/core/submission.d.ts +24 -24
  48. package/lib/core/submission.js +21 -21
  49. package/lib/core/task.d.ts +17 -16
  50. package/lib/core/task.js +14 -13
  51. package/lib/core/tracing.d.ts +20 -20
  52. package/lib/core/tracing.js +20 -20
  53. package/lib/core/widths.d.ts +2 -2
  54. package/lib/core/widths.js +5 -5
  55. package/lib/core/work.d.ts +18 -18
  56. package/lib/core/work.js +21 -21
  57. package/lib/core/zoom.d.ts +34 -0
  58. package/lib/core/zoom.js +64 -0
  59. package/lib/element/icons.d.ts +19 -1
  60. package/lib/element/icons.js +24 -2
  61. package/lib/element/index.d.ts +87 -87
  62. package/lib/element/index.js +397 -295
  63. package/lib/element/labels.d.ts +21 -18
  64. package/lib/element/labels.js +15 -12
  65. package/lib/element/notation.d.ts +2 -0
  66. package/lib/element/notation.js +94 -0
  67. package/lib/element/parts.d.ts +2 -2
  68. package/lib/element/parts.js +6 -6
  69. package/lib/element/pictures.js +1 -1
  70. package/lib/element/probe.d.ts +2 -2
  71. package/lib/element/probe.js +3 -3
  72. package/lib/element/session.d.ts +3 -0
  73. package/lib/element/session.js +8 -4
  74. package/lib/element/statement.d.ts +2 -2
  75. package/lib/element/statement.js +6 -6
  76. package/lib/element/tools.d.ts +21 -18
  77. package/lib/element/tools.js +46 -30
  78. package/lib/element/tracing.js +58 -31
  79. package/package.json +3 -3
package/lib/core/work.js CHANGED
@@ -6,8 +6,8 @@ import { GROUP_RULE } from "./groups.js";
6
6
  import { frozen, historyOf, sameEvent } from "./history.js";
7
7
  /**
8
8
  * The work on the sheet: the strokes in sight, the stack of the actions that undo takes back, the
9
- * last first (R19), and the history of writing, every action as an event at the sheet's time
10
- * (R22). Clearing and erasing are actions too, so undo brings their strokes back. Nothing is
9
+ * last first, and the history of writing, every action as an event at the sheet's time.
10
+ * Clearing and erasing are actions too, so undo brings their strokes back. Nothing is
11
11
  * redone. The times its methods take are the page's, and the sheet's clock turns one into the
12
12
  * sheet's time only when the action lands: an undo that has nothing to take back is no event. A
13
13
  * history given to the sheet is replayed by the same rules, each action at its own time (R27).
@@ -28,21 +28,21 @@ export class Work {
28
28
  #index = new RBush();
29
29
  #indexed = this.#strokes;
30
30
  #entries = new WeakMap();
31
- /** The IDs of the strokes written on the tracing paper of a task from paper (R87). */
31
+ /** The IDs of the strokes written on the tracing paper of a task from paper. */
32
32
  #tracing = new Set();
33
33
  constructor(clock = new Clock()) {
34
34
  this.#clock = clock;
35
35
  }
36
36
  /**
37
- * The work a history of writing given to the sheet leaves (R27): its strokes, its stack of
37
+ * The work a history of writing given to the sheet leaves: its strokes, its stack of
38
38
  * actions for undo and the history itself, in frozen objects of the work's own. The events are
39
- * checked as `historyOf` checks them, then replayed by the work's own rules, each at its own time,
40
- * and each must be what the work records for it: an erasing takes off strokes on the sheet, in
41
- * the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back the
42
- * last action still in force and says what the stack says. A history the sheet could not have
39
+ * checked as `historyOf` checks them, then replayed by the work's own rules, each at its own
40
+ * time, and each must be what the work records for it: an erasing takes off strokes on the sheet,
41
+ * in the sheet's order; a clearing clears a sheet with strokes, all of them; an undo takes back
42
+ * the last action still in force and says what the stack says. A history the sheet could not have
43
43
  * written is a TypeError that names the event. The clock is not asked: it goes on as the sheet
44
- * that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may
45
- * be the tracing paper's (R87).
44
+ * that takes the work tells it (`Clock.resume`). On a task from paper, `paper`, a stroke may be
45
+ * the tracing paper's.
46
46
  */
47
47
  static restore(value, clock, paper = false) {
48
48
  const work = new Work(clock);
@@ -63,15 +63,15 @@ export class Work {
63
63
  return this.#strokes;
64
64
  }
65
65
  /**
66
- * Whether undo has an action to take back (R19): the stack is not empty. The element's Undo
67
- * button stands unavailable while it is (R28).
66
+ * Whether undo has an action to take back: the stack is not empty. The element's Undo
67
+ * button stands unavailable while it is.
68
68
  */
69
69
  get undoable() {
70
70
  return this.#done.length > 0;
71
71
  }
72
72
  /**
73
73
  * Whether a stroke of this ID was written on the tracing paper of a task from paper, its points
74
- * from the paper's corner (R87).
74
+ * from the paper's corner.
75
75
  */
76
76
  onTracing(id) {
77
77
  return this.#tracing.has(id);
@@ -94,7 +94,7 @@ export class Work {
94
94
  * than a longer one, for an array once handed out never changes: a clearing keeps the one it
95
95
  * cleared, and whoever read `strokes` keeps what they read. It lands at the sheet's latest time:
96
96
  * its last point's, unless an action landed while it was under way and it ended without its
97
- * pointerup, its last point earlier. A stroke on the tracing paper says so, `on` (R87).
97
+ * pointerup, its last point earlier. A stroke on the tracing paper says so, `on`.
98
98
  */
99
99
  write(stroke, on) {
100
100
  this.#write(stroke, Math.max(this.#clock.latest, stroke.points.at(-1)?.t ?? 0), on);
@@ -120,9 +120,9 @@ export class Work {
120
120
  /**
121
121
  * The strokes on the sheet whose line comes within `reach` of the segment from `from` to `to`, in
122
122
  * sheet units: the index finds those whose box is near enough, and the distance to each segment
123
- * of their points decides (R05). A segment whose ends are one point is that point. On a task from
123
+ * of their points decides. A segment whose ends are one point is that point. On a task from
124
124
  * paper an erasing takes the strokes of one layer alone, `layer`: the tracing paper's, its
125
- * points from its corner, or the sheet's (R87).
125
+ * points from its corner, or the sheet's.
126
126
  */
127
127
  near(from, to, reach, layer) {
128
128
  const hits = [];
@@ -137,8 +137,8 @@ export class Work {
137
137
  // The actions, each with the sheet's time it lands at, asked for only once it does.
138
138
  #write(stroke, t, on) {
139
139
  // A history replayed writes its strokes one after another, without a copy of the sheet for
140
- // each: thousands of strokes would copy the sheet thousands of times. A clearing keeps the array
141
- // it cleared and leaves the sheet a new one, so no array an action keeps grows by it.
140
+ // each: thousands of strokes would copy the sheet thousands of times. A clearing keeps the
141
+ // array it cleared and leaves the sheet a new one, so no array an action keeps grows by it.
142
142
  if (this.#replaying)
143
143
  this.#strokes.push(stroke);
144
144
  else
@@ -246,7 +246,7 @@ export class Work {
246
246
  return entry;
247
247
  }
248
248
  }
249
- /** The ID the next stroke takes after a history (R27): one past the highest written, or 1. */
249
+ /** The ID the next stroke takes after a history: one past the highest written, or 1. */
250
250
  export function nextIdOf(history) {
251
251
  let highest = 0;
252
252
  for (const event of history) {
@@ -256,8 +256,8 @@ export function nextIdOf(history) {
256
256
  return highest + 1;
257
257
  }
258
258
  /**
259
- * Where the sheet's clock goes on after a history given to it (R27): past its last event by more
260
- * than the pause of the groups (R24), so that the first stroke after it is no neighbour of its
259
+ * Where the sheet's clock goes on after a history given to it: past its last event by more
260
+ * than the pause of the groups, so that the first stroke after it is no neighbour of its
261
261
  * strokes; at 0 after an empty history, which is a new sheet's.
262
262
  */
263
263
  export function resumeOf(history) {
@@ -0,0 +1,34 @@
1
+ /** The smallest and the largest zoom of the sheet: half its fit, and twice it (R73). */
2
+ export declare const ZOOM_MIN = 0.5;
3
+ export declare const ZOOM_MAX = 2;
4
+ /**
5
+ * The step of Zoom in and Zoom out, a quarter of the fit: from any zoom a pinch left, a
6
+ * press goes to the next quarter, so 50, 75, … 200 % are where the buttons stop.
7
+ */
8
+ export declare const ZOOM_STEP = 0.25;
9
+ /** The zoom `value` kept within its bounds; anything that is not a number is the fit. */
10
+ export declare function clampZoom(value: number): number;
11
+ /**
12
+ * The next quarter from `value`, larger or smaller, within the bounds. A zoom within a hair of a
13
+ * quarter counts as that quarter, so that the arithmetic of a pinch never makes a press a no-op.
14
+ */
15
+ export declare function stepZoom(value: number, larger: boolean): number;
16
+ /**
17
+ * The page's zoom: one for every sheet of the page, from 100 % when the page is loaded, as
18
+ * the pen mode is. The next task is a new element, and the zoom stays: a learner who
19
+ * needs it larger or smaller asks once. It lives in memory alone: nothing is stored or sent.
20
+ */
21
+ export declare class PageZoom {
22
+ #private;
23
+ /** The zoom now: 1 for the fit, 2 for twice it, 0.5 for half. */
24
+ get value(): number;
25
+ /** Whether there is a larger zoom to go to, for Zoom in, or a smaller one, for Zoom out. */
26
+ get larger(): boolean;
27
+ get smaller(): boolean;
28
+ /** A step to the next quarter, larger or smaller, if there is one. */
29
+ step(larger: boolean): boolean;
30
+ /** The zoom set to `value` within its bounds — a pinch's —: every watcher hears of a change. */
31
+ set(value: number): boolean;
32
+ /** `watcher` hears of every change from now on, until the function this gives is called. */
33
+ watch(watcher: () => void): () => void;
34
+ }
@@ -0,0 +1,64 @@
1
+ /** The smallest and the largest zoom of the sheet: half its fit, and twice it (R73). */
2
+ export const ZOOM_MIN = 0.5;
3
+ export const ZOOM_MAX = 2;
4
+ /**
5
+ * The step of Zoom in and Zoom out, a quarter of the fit: from any zoom a pinch left, a
6
+ * press goes to the next quarter, so 50, 75, … 200 % are where the buttons stop.
7
+ */
8
+ export const ZOOM_STEP = 0.25;
9
+ /** The zoom `value` kept within its bounds; anything that is not a number is the fit. */
10
+ export function clampZoom(value) {
11
+ if (!Number.isFinite(value))
12
+ return 1;
13
+ return Math.min(Math.max(value, ZOOM_MIN), ZOOM_MAX);
14
+ }
15
+ /**
16
+ * The next quarter from `value`, larger or smaller, within the bounds. A zoom within a hair of a
17
+ * quarter counts as that quarter, so that the arithmetic of a pinch never makes a press a no-op.
18
+ */
19
+ export function stepZoom(value, larger) {
20
+ const quarters = value / ZOOM_STEP;
21
+ const next = larger ? Math.floor(quarters + 1e-6) + 1 : Math.ceil(quarters - 1e-6) - 1;
22
+ return clampZoom(next * ZOOM_STEP);
23
+ }
24
+ /**
25
+ * The page's zoom: one for every sheet of the page, from 100 % when the page is loaded, as
26
+ * the pen mode is. The next task is a new element, and the zoom stays: a learner who
27
+ * needs it larger or smaller asks once. It lives in memory alone: nothing is stored or sent.
28
+ */
29
+ export class PageZoom {
30
+ #value = 1;
31
+ #watchers = new Set();
32
+ /** The zoom now: 1 for the fit, 2 for twice it, 0.5 for half. */
33
+ get value() {
34
+ return this.#value;
35
+ }
36
+ /** Whether there is a larger zoom to go to, for Zoom in, or a smaller one, for Zoom out. */
37
+ get larger() {
38
+ return this.#value < ZOOM_MAX;
39
+ }
40
+ get smaller() {
41
+ return this.#value > ZOOM_MIN;
42
+ }
43
+ /** A step to the next quarter, larger or smaller, if there is one. */
44
+ step(larger) {
45
+ return this.set(stepZoom(this.#value, larger));
46
+ }
47
+ /** The zoom set to `value` within its bounds — a pinch's —: every watcher hears of a change. */
48
+ set(value) {
49
+ const next = clampZoom(value);
50
+ if (next === this.#value)
51
+ return false;
52
+ this.#value = next;
53
+ for (const watcher of [...this.#watchers])
54
+ watcher();
55
+ return true;
56
+ }
57
+ /** `watcher` hears of every change from now on, until the function this gives is called. */
58
+ watch(watcher) {
59
+ this.#watchers.add(watcher);
60
+ return () => {
61
+ this.#watchers.delete(watcher);
62
+ };
63
+ }
64
+ }
@@ -68,6 +68,14 @@ export declare const ICONS: {
68
68
  readonly viewBox: "0 0 24 24";
69
69
  readonly paths: readonly ["M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h3.325v-3.325H5zm5.325 0h3.35v-3.325h-3.35zm5.35 0H19v-3.325h-3.325zM5 13.675h3.325v-3.35H5zm5.325 0h3.35v-3.35h-3.35zm5.35 0H19v-3.35h-3.325zM5 8.325h3.325V5H5zm5.325 0h3.35V5h-3.35zm5.35 0H19V5h-3.325z"];
70
70
  };
71
+ readonly "zoom-in-outline-rounded": {
72
+ readonly viewBox: "0 0 24 24";
73
+ readonly paths: readonly ["M8.5 10.5h-1q-.425 0-.712-.288T6.5 9.5t.288-.712T7.5 8.5h1v-1q0-.425.288-.712T9.5 6.5t.713.288t.287.712v1h1q.425 0 .713.288t.287.712t-.288.713t-.712.287h-1v1q0 .425-.288.713T9.5 12.5t-.712-.288T8.5 11.5zm1 5.5q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l5.6 5.6q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-5.6-5.6q-.75.6-1.725.95T9.5 16m0-2q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14"];
74
+ };
75
+ readonly "zoom-out-outline-rounded": {
76
+ readonly viewBox: "0 0 24 24";
77
+ readonly paths: readonly ["M8 10.5q-.425 0-.712-.288T7 9.5t.288-.712T8 8.5h3q.425 0 .713.288T12 9.5t-.288.713T11 10.5zM9.5 16q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l5.6 5.6q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-5.6-5.6q-.75.6-1.725.95T9.5 16m0-2q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14"];
78
+ };
71
79
  readonly "remove-outline-rounded": {
72
80
  readonly viewBox: "0 0 24 24";
73
81
  readonly paths: readonly ["M6 13q-.425 0-.712-.288T5 12t.288-.712T6 11h12q.425 0 .713.288T19 12t-.288.713T18 13z"];
@@ -162,12 +170,22 @@ export declare const ROW: {
162
170
  readonly filled: "grid-on-outline-rounded";
163
171
  readonly mirrored: false;
164
172
  };
173
+ readonly zoomIn: {
174
+ readonly outline: "zoom-in-outline-rounded";
175
+ readonly filled: "zoom-in-outline-rounded";
176
+ readonly mirrored: false;
177
+ };
165
178
  readonly zoomOut: {
179
+ readonly outline: "zoom-out-outline-rounded";
180
+ readonly filled: "zoom-out-outline-rounded";
181
+ readonly mirrored: false;
182
+ };
183
+ readonly smaller: {
166
184
  readonly outline: "remove-outline-rounded";
167
185
  readonly filled: "remove-outline-rounded";
168
186
  readonly mirrored: false;
169
187
  };
170
- readonly zoomIn: {
188
+ readonly larger: {
171
189
  readonly outline: "add-outline-rounded";
172
190
  readonly filled: "add-outline-rounded";
173
191
  readonly mirrored: false;
@@ -106,6 +106,18 @@ export const ICONS = {
106
106
  "M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21zm0-2h3.325v-3.325H5zm5.325 0h3.35v-3.325h-3.35zm5.35 0H19v-3.325h-3.325zM5 13.675h3.325v-3.35H5zm5.325 0h3.35v-3.35h-3.35zm5.35 0H19v-3.35h-3.325zM5 8.325h3.325V5H5zm5.325 0h3.35V5h-3.35zm5.35 0H19V5h-3.325z",
107
107
  ],
108
108
  },
109
+ "zoom-in-outline-rounded": {
110
+ viewBox: "0 0 24 24",
111
+ paths: [
112
+ "M8.5 10.5h-1q-.425 0-.712-.288T6.5 9.5t.288-.712T7.5 8.5h1v-1q0-.425.288-.712T9.5 6.5t.713.288t.287.712v1h1q.425 0 .713.288t.287.712t-.288.713t-.712.287h-1v1q0 .425-.288.713T9.5 12.5t-.712-.288T8.5 11.5zm1 5.5q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l5.6 5.6q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-5.6-5.6q-.75.6-1.725.95T9.5 16m0-2q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14",
113
+ ],
114
+ },
115
+ "zoom-out-outline-rounded": {
116
+ viewBox: "0 0 24 24",
117
+ paths: [
118
+ "M8 10.5q-.425 0-.712-.288T7 9.5t.288-.712T8 8.5h3q.425 0 .713.288T12 9.5t-.288.713T11 10.5zM9.5 16q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l5.6 5.6q.275.275.275.7t-.275.7t-.7.275t-.7-.275l-5.6-5.6q-.75.6-1.725.95T9.5 16m0-2q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14",
119
+ ],
120
+ },
109
121
  "remove-outline-rounded": {
110
122
  viewBox: "0 0 24 24",
111
123
  paths: [
@@ -188,8 +200,18 @@ export const ROW = {
188
200
  filled: "grid-on-outline-rounded",
189
201
  mirrored: false,
190
202
  },
191
- zoomOut: { outline: "remove-outline-rounded", filled: "remove-outline-rounded", mirrored: false },
192
- zoomIn: { outline: "add-outline-rounded", filled: "add-outline-rounded", mirrored: false },
203
+ zoomIn: {
204
+ outline: "zoom-in-outline-rounded",
205
+ filled: "zoom-in-outline-rounded",
206
+ mirrored: false,
207
+ },
208
+ zoomOut: {
209
+ outline: "zoom-out-outline-rounded",
210
+ filled: "zoom-out-outline-rounded",
211
+ mirrored: false,
212
+ },
213
+ smaller: { outline: "remove-outline-rounded", filled: "remove-outline-rounded", mirrored: false },
214
+ larger: { outline: "add-outline-rounded", filled: "add-outline-rounded", mirrored: false },
193
215
  fit: {
194
216
  outline: "fit-screen-outline-rounded",
195
217
  filled: "fit-screen-outline-rounded",
@@ -6,12 +6,12 @@ import { type Manifest } from "../core/manifest.js";
6
6
  import { type Marks } from "../core/marks.js";
7
7
  import { type Task, type Tool } from "../core/task.js";
8
8
  /**
9
- * The types of the contract of canvas and app are spec's (R74 spec; R07): the element as
9
+ * The types of the contract of canvas and app are spec's: the element as
10
10
  * CanvasElement has it, what its events tell and the work it gives for checking, here, and the data
11
11
  * — the history of writing, the context of a submission, the filled slots and the state of a demo
12
12
  * — through the DOM-free part. The entry point gives them under spec's names, the same types, the
13
13
  * media and the tutor's marks too. The crop and a task with its temporary tools are the element's
14
- * own (R26, R41).
14
+ * own.
15
15
  */
16
16
  export type { Box, CanvasElement, CanvasEventMap, DemoChangeEvent, ExportedCell, ExportedPaper, ExportedSheet, ExportedWork, ExportedWorkbook, GridChange, GridChangeEvent, HistoryChange, HistoryChangeEvent, Media, PaperGrid, PaperTask, ToolChange, ToolChangeEvent, TracingChangeEvent, TracingReadEvent, TracingReading, TracingState, } from "@altnovatrail/spec/canvas";
17
17
  export type { Filled, Filling } from "../core/boxes.js";
@@ -27,46 +27,46 @@ export type { Canvas, Task, Tool } from "../core/task.js";
27
27
  /** The name the element is registered under. */
28
28
  export declare const TAG = "novatrail-canvas";
29
29
  /**
30
- * The element `<novatrail-canvas>`: the contract's `CanvasElement` (R74 spec), and beyond it the
30
+ * The element `<novatrail-canvas>`: the contract's `CanvasElement`, and beyond it the
31
31
  * commands undo and clear, which the contract does not name.
32
32
  */
33
33
  export declare class NovatrailCanvas extends HTMLElement implements CanvasElement {
34
34
  #private;
35
35
  constructor();
36
- /** The element follows its own `lang`: its buttons are labelled in it (R07, R28). */
36
+ /** The element follows its own `lang`: its buttons are labelled in it. */
37
37
  static readonly observedAttributes: string[];
38
38
  /**
39
- * What a press of the primary button does: "pen" writes, as the element starts, "eraser" erases
40
- * (R22), and "hand" moves the sheet, under any pointer (R88). The learner switches it with the
39
+ * What a press of the primary button does: "pen" writes, as the element starts, "eraser" erases,
40
+ * and "hand" moves the sheet, under any pointer. The learner switches it with the
41
41
  * element's own buttons, which say a choice of theirs with a `toolchange`, and the consumer may
42
- * set it too, which says nothing (R28). A press under way goes on as it began. A pen's eraser
42
+ * set it too, which says nothing. A press under way goes on as it began. A pen's eraser
43
43
  * erases whatever the tool but the hand. A task without the eraser has none of it: "eraser" is a
44
44
  * TypeError then, and a new task without it puts the pen back. Every sheet the learner writes on
45
- * has the hand. A worked example has the pen alone, which writes nothing on its sheet (R42).
45
+ * has the hand. A worked example has the pen alone, which writes nothing on its sheet.
46
46
  */
47
47
  get tool(): Tool;
48
48
  set tool(tool: Tool);
49
49
  /**
50
- * The open view of the task, of the module format 0.4 (R32): its ID, its statement, which the
51
- * element shows above the page (R23), what the statement gives and asks, which app shows (R57
52
- * spec), its canvas — the kind, the sheet's grid and the tools the task allows (R28) — and its
53
- * items. A workbook's items are its lines, which the template shows, laid out on the page (R35,
54
- * R36). The type is spec's, with the element's own tools (R73 spec; R41). A task the schema
50
+ * The open view of the task, of the module format 0.4: its ID, its statement, which the
51
+ * element shows above the page, what the statement gives and asks, which app shows, its
52
+ * canvas — the kind, the sheet's grid and the tools the task allows — and its
53
+ * items. A workbook's items are its lines, which the template shows, laid out on the page. The
54
+ * type is spec's, with the element's own tools. A task the schema
55
55
  * refuses is a TypeError that names the field, a field the open view has not among it, and so are
56
- * a workbook whose lines do not fit, at the first item that does not (R35), and an answer slot in
56
+ * a workbook whose lines do not fit, at the first item that does not, and an answer slot in
57
57
  * a zone; the sheet passes over a choice and an item's text, which app shows. Another task of the
58
58
  * same layer, tools and statement changes nothing, and any other changes the template alone, of
59
- * either kind: the work stays, for the next task is a new element (R20). A task without the
59
+ * either kind: the work stays, for the next task is a new element. A task without the
60
60
  * eraser puts the pen back, with no event. While a worked example is shown a task is a TypeError,
61
- * and `undefined` changes nothing: the element shows one or the other (R42).
61
+ * and `undefined` changes nothing: the element shows one or the other.
62
62
  */
63
63
  get task(): Task | undefined;
64
64
  set task(task: Task | undefined);
65
65
  /**
66
- * A lesson's worked example (R42; R58 spec): the open view of a segment `worked_example` of the
67
- * module format 0.4 — its statement, which the element shows above the sheet as a task's (R23),
66
+ * A lesson's worked example: the open view of a segment `worked_example` of the
67
+ * module format 0.4 — its statement, which the element shows above the sheet as a task's,
68
68
  * the grid of its sheet or the lines of its workbook, and the parts of the author's demo, which
69
- * on a workbook fill the lines' boxes with their values (R61). The type is spec's (R73 spec; R41).
69
+ * on a workbook fill the lines' boxes with their values. The type is spec's.
70
70
  * The element shows a task or a worked example, not both: an example while a task is given, while
71
71
  * the sheet has a history of writing, or while a stroke or an erasing is under way, is a
72
72
  * TypeError, and so is one the schema refuses, at its field. `undefined` takes the example off,
@@ -75,9 +75,9 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
75
75
  *
76
76
  * On a worked example's sheet the learner does not write: the canvas takes no input, and a finger
77
77
  * or a pen there scrolls the sheet as the browser scrolls the statement. It has no bar: its row
78
- * holds Next and Demo, and its region is named a worked example's. `task`, `history` other than the empty one and
79
- * `marks` are TypeErrors, and so is an eraser: the tool is the pen alone, and `exportWork()` and
80
- * `filled` give null. The next segment of a lesson is a new element (R20).
78
+ * holds Next and Demo, and its region is named a worked example's. `task`, `history` other than
79
+ * the empty one and `marks` are TypeErrors, and so is an eraser: the tool is the pen alone, and
80
+ * `exportWork()` and `filled` give null. The next segment of a lesson is a new element.
81
81
  *
82
82
  * The parts of the demo the learner opens one at a time with the row's Next, into a list between
83
83
  * the statement and the sheet, and hides and shows whole with Demo; `demoState` tells how far
@@ -86,33 +86,34 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
86
86
  get workedExample(): WorkedExample | undefined;
87
87
  set workedExample(example: WorkedExample | undefined);
88
88
  /**
89
- * A task from the learner's paper (R87; R162 spec): `statement`, the task's crop as app cut it, a
89
+ * A task from the learner's paper: `statement`, the task's crop as app cut it, a
90
90
  * Blob of a JPEG or a PNG. The element shows it in place of a task and of a worked example: a
91
91
  * dotted sheet with no statement, the pen and the eraser, and the crop over it as tracing paper,
92
92
  * at the element's own place for it, shown, which `tracing` tells. While a task or an example is
93
93
  * shown it is a TypeError, and so is what is not such a task. Another task from paper, of
94
94
  * another crop, lays its crop at the start again, and the history stays: the next task is a new
95
- * element (R20); one of the same crop changes nothing. `undefined` takes it off, but not while the
96
- * history has strokes on the tracing paper, a TypeError. Either drops a stroke or an erasing under
97
- * way on the tracing paper, as a new history drops the one under the pen. The crop's picture is
98
- * read as it comes; till then the paper has its largest size.
95
+ * element; one of the same crop changes nothing. `undefined` takes it off, but not while the
96
+ * history has strokes on the tracing paper, a TypeError. Either drops a stroke or an erasing
97
+ * under way on the tracing paper, as a new history drops the one under the pen. The crop's
98
+ * picture is read as it comes; till then the paper has its largest size.
99
99
  */
100
100
  get paper(): PaperTask | undefined;
101
101
  set paper(paper: PaperTask | undefined);
102
102
  /**
103
103
  * Where the tracing paper of the task from paper lies on the sheet, its top left corner in sheet
104
- * units, and whether it is hidden (R87): frozen, and the same object until it changes;
105
- * `undefined` without a task from paper. The learner moves it by its grip and hides or shows it by
106
- * the button atop the tools, which a `tracingchange` tells; the consumer keeps it and gives it
107
- * back, which tells nothing. Given before the task from paper it is a TypeError, and so is a state
108
- * that is not one, or one that puts the paper wholly off the sheet; `undefined` changes nothing.
109
- * Till the crop's picture is read the paper has its largest size: a state that puts the paper of
110
- * its real size wholly off the sheet then moves to the nearest place wholly on it, with no event.
104
+ * units, and whether it is hidden: frozen, and the same object until it changes;
105
+ * `undefined` without a task from paper. The learner moves it by its grip and hides or shows it
106
+ * by the button atop the tools, which a `tracingchange` tells; the consumer keeps it and gives it
107
+ * back, which tells nothing. Given before the task from paper it is a TypeError, and so is a
108
+ * state that is not one, or one that puts the paper wholly off the sheet; `undefined` changes
109
+ * nothing. Till the crop's picture is read the paper has its largest size: a state that puts the
110
+ * paper of its real size wholly off the sheet then moves to the nearest place wholly on it, with
111
+ * no event.
111
112
  */
112
113
  get tracing(): TracingState | undefined;
113
114
  set tracing(state: TracingState | undefined);
114
115
  /**
115
- * The reading of the task from paper's statement in clean print (R89): `undefined` offers no
116
+ * The reading of the task from paper's statement in clean print: `undefined` offers no
116
117
  * "Recognise"; `"ready"` offers it, and its press sends a `tracingread`; `"busy"` waits; `"done"`
117
118
  * holds the statements, which take the crop's place for the learner who asked, till "Original".
118
119
  * Frozen; given without a task from paper, or not a reading, it is a TypeError.
@@ -120,7 +121,7 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
120
121
  get reading(): TracingReading | undefined;
121
122
  set reading(reading: TracingReading | undefined);
122
123
  /**
123
- * How far the learner has gone through the worked example's demo (R42): `opened`, how many of
124
+ * How far the learner has gone through the worked example's demo: `opened`, how many of
124
125
  * its parts are open, from the first, and `hidden`, whether the whole demo is hidden — frozen,
125
126
  * and the same object until it changes. A new example starts at `{ opened: 0, hidden: false }`,
126
127
  * and without one it is `undefined`. The learner changes it with the row's Next and Demo, which
@@ -134,8 +135,8 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
134
135
  get demoState(): DemoState | undefined;
135
136
  set demoState(state: DemoState | undefined);
136
137
  /**
137
- * The open view of the module's manifest (R32), of which the element reads the version of the
138
- * module format — "0.4", or the manifest is a TypeError (R44 spec) — the height of a digit on the
138
+ * The open view of the module's manifest, of which the element reads the version of the
139
+ * module format — "0.4", or the manifest is a TypeError — the height of a digit on the
139
140
  * crop for checking, `canvas.digit_height`, 24 px unless given, and the explanation language, the
140
141
  * statement's and a workbook's lines'. Without a manifest the digits are 24 px, and the statement
141
142
  * and the lines are in the element's own `lang`. The rest of it the element passes over, but for
@@ -143,14 +144,14 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
143
144
  * cannot read is a TypeError that names the field, and the element stays as it was; the same
144
145
  * object given again is read again, for the consumer may have changed it. The task and the
145
146
  * manifest are each the consumer's to give, in either order: `exportWork()` takes the height
146
- * when it is called (R27).
147
+ * when it is called.
147
148
  */
148
149
  get manifest(): Manifest | undefined;
149
150
  set manifest(manifest: Manifest | undefined);
150
151
  /**
151
- * What gives the files of the pictures, by their references, as the contract has it (R07;
152
- * R36 spec): a task's statement's, and a worked example's — its statement's and every part's of
153
- * its demo, which it asks for as the example comes, before the learner opens them (R42). A
152
+ * What gives the files of the pictures, by their references, as the contract has it: a
153
+ * task's statement's, and a worked example's — its statement's and every part's of
154
+ * its demo, which it asks for as the example comes, before the learner opens them. A
154
155
  * reference is asked for once, whichever pictures show it, and its file stays while the task or
155
156
  * the example names it. Until a picture's file comes, or if it never does, its frame shows what
156
157
  * it shows in words. A new function serves the references that have no file yet, and stops no
@@ -159,7 +160,7 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
159
160
  get media(): Media | undefined;
160
161
  set media(media: Media | undefined);
161
162
  /**
162
- * The grid of the task from paper's sheet (R88): `undefined` without a task from paper, and
163
+ * The grid of the task from paper's sheet: `undefined` without a task from paper, and
163
164
  * "dots" as one comes. The learner turns it by the element's button, which a `gridchange`
164
165
  * tells; the consumer keeps it and gives it back, which tells nothing. A grid given before the
165
166
  * task from paper is a TypeError, and so is one not of `PaperGrid`; `undefined` changes nothing.
@@ -167,7 +168,7 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
167
168
  get grid(): PaperGrid | undefined;
168
169
  set grid(grid: PaperGrid | undefined);
169
170
  /**
170
- * The history of writing (R22, R27): every stroke, erasing, clearing and undo on the sheet, in the
171
+ * The history of writing: every stroke, erasing, clearing and undo on the sheet, in the
171
172
  * order they landed, at the sheet's time — frozen, and the same array until the next action. The
172
173
  * consumer keeps it, adding what `historychange` tells, and gives it back to open the sheet as it
173
174
  * was: the strokes, and the actions undo takes back.
@@ -181,95 +182,94 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
181
182
  * event, the next stroke takes the next ID, and the tutor's marks go back on the strokes, or off,
182
183
  * if the history has not their strokes. A history that is where the sheet's began loses what came
183
184
  * after, and says so in the console. The task and the history are each the consumer's to give, in
184
- * either order. A worked example's sheet has the empty history alone: any other is a TypeError
185
- * (R42).
185
+ * either order. A worked example's sheet has the empty history alone: any other is a TypeError.
186
186
  */
187
187
  get history(): readonly HistoryEvent[];
188
188
  set history(history: readonly HistoryEvent[] | undefined);
189
189
  /**
190
190
  * Which answer slots the learner's strokes fill, per item, per slot, in the task's order, by the
191
191
  * strokes `exportWork()` would take — not the stroke under way, but those under an eraser not
192
- * yet lifted. A workbook's boxes, each whether it holds one (R34, R37): a stroke is in one box
193
- * or in none, by the rule of R37, and what is in none is the draft. A sheet's one answer anywhere
194
- * on it or the whole sheet, whether the sheet holds one (R42). `null` for a sheet of choices,
192
+ * yet lifted. A workbook's boxes, each whether it holds one: a stroke is in one box
193
+ * or in none, by the boxes' rule, and what is in none is the draft. A sheet's one answer anywhere
194
+ * on it or the whole sheet, whether the sheet holds one. `null` for a sheet of choices,
195
195
  * whose options app marks, for a sheet with no task, and for a worked example. Frozen, and the
196
196
  * same array until a slot changes. An action on the sheet changes it before its
197
197
  * `historychange`, and a task or a history given changes it with no event.
198
198
  */
199
199
  get filled(): Filled | null;
200
200
  /**
201
- * The tutor's marks of one submission, with the context the element gave with its work (R07,
202
- * R26): each a frame where a group of strokes is, or a box on the crop the model saw, and on a
203
- * workbook where an answer cell is, by its item and its slot (R39). A mark holds on to the
204
- * strokes the model saw there and is drawn around those of them the sheet shows, as they are now
205
- * — a cell's around its box too: new strokes do not move it, and when all of them are erased it
206
- * is gone, till undo brings them back. A box of a workbook that was empty is framed alone (R74
207
- * spec). A box that comes near no stroke, and a cell on a sheet, which takes no zones, have no
208
- * frame: the question is asked without one. The type is spec's (R83 spec). A submission goes back
209
- * to a sheet whose history holds its strokes, as its digest tells (R27), and a workbook's to a
210
- * page of its boxes: one of other strokes or other boxes is a TypeError, and so are marks
211
- * given before the task and the history they hold on to, and marks that are not marks. A new
212
- * history, and a new page, put the marks back on their strokes, or take them off. `undefined`
213
- * takes the marks off. Every value is checked as it comes, and marks equal to those shown write
214
- * nothing. A worked example's sheet has nothing to mark: marks are a TypeError there (R42).
201
+ * The tutor's marks of one submission, with the context the element gave with its work: each a
202
+ * frame where a group of strokes is, or a box on the crop the model saw, and on a workbook where
203
+ * an answer cell is, by its item and its slot. A mark holds on to the strokes the model saw there
204
+ * and is drawn around those of them the sheet shows, as they are now — a cell's around its box
205
+ * too: new strokes do not move it, and when all of them are erased it is gone, till undo brings
206
+ * them back. A box of a workbook that was empty is framed alone. A box that comes near no stroke,
207
+ * and a cell on a sheet, which takes no zones, have no frame: the question is asked without one.
208
+ * The type is spec's. A submission goes back to a sheet whose history holds its strokes, as its
209
+ * digest tells, and a workbook's to a page of its boxes: one of other strokes or other boxes is a
210
+ * TypeError, and so are marks given before the task and the history they hold on to, and marks
211
+ * that are not marks. A new history, and a new page, put the marks back on their strokes, or take
212
+ * them off. `undefined` takes the marks off. Every value is checked as it comes, and marks equal
213
+ * to those shown write nothing. A worked example's sheet has nothing to mark: marks are a
214
+ * TypeError there.
215
215
  */
216
216
  get marks(): Marks | undefined;
217
217
  set marks(marks: Marks | undefined);
218
- /** The element moved into another document: its root adopts that document's sheet (R51). */
218
+ /** The element moved into another document: its root adopts that document's sheet. */
219
219
  adoptedCallback(): void;
220
220
  connectedCallback(): void;
221
221
  /**
222
222
  * The element's `lang` came, changed or went: its buttons and a workbook's boxes are labelled in
223
- * it, or in English for a language their labels are not in, and for none (R28, R36). Or
223
+ * it, or in English for a language their labels are not in, and for none. Or
224
224
  * `tools-hidden` did: while the element has it, the bar is out of sight and of the accessibility
225
- * tree, as `app` hides it on a phone under its tutor's sheet (R84; R36 spec). An attribute the
225
+ * tree, as `app` hides it on a phone under its tutor's sheet. An attribute the
226
226
  * element had before it was defined comes here just after the constructor, which reads no
227
227
  * attribute.
228
228
  */
229
229
  attributeChangedCallback(name: string): void;
230
230
  /**
231
231
  * Takes back the last action on the sheet — the last stroke written, the last erasing, or the
232
- * clearing — and says whether there was one (R19, R22), with a `historychange` if there was
233
- * (R27). The element's Undo button calls it, and so may the consumer (R28). A stroke under way
232
+ * clearing — and says whether there was one, with a `historychange` if there was.
233
+ * The element's Undo button calls it, and so may the consumer. A stroke under way
234
234
  * stays: it lands when it ends. So does an erasing: what it came near leaves the sheet when it
235
235
  * lifts, if it is on the sheet then.
236
236
  */
237
237
  undo(): boolean;
238
238
  /**
239
239
  * Takes every stroke off the sheet, an action that undo takes back, and says whether there were
240
- * any (R19), with a `historychange` if there were (R27). The element's Clear button calls it, and
241
- * so may the consumer (R28). A stroke under way stays: it lands when it ends.
240
+ * any, with a `historychange` if there were. The element's Clear button calls it, and
241
+ * so may the consumer. A stroke under way stays: it lands when it ends.
242
242
  */
243
243
  clear(): boolean;
244
244
  /**
245
- * The work for checking (R07, R27), when the consumer asks for it, at Check, at the height of a
246
- * digit the manifest asks for (R25, R32). On a sheet it is the crop of the strokes the sheet
245
+ * The work for checking, when the consumer asks for it, at Check, at the height of a
246
+ * digit the manifest asks for. On a sheet it is the crop of the strokes the sheet
247
247
  * shows, its PNG, and the context of the submission — the crop's numbers, the groups and their
248
- * digest (R26, R27). On a workbook it is the crop of each filled box, by its strokes alone, with
249
- * its item and its slot, and the context — the table «box → stroke IDs» and its digest (R34,
250
- * R38); the draft goes nowhere. The consumer keeps the context, sends only the PNGs and their
251
- * places to be checked (R09 spec), and gives the context back with the tutor's marks. It is the
248
+ * digest. On a workbook it is the crop of each filled box, by its strokes alone, with
249
+ * its item and its slot, and the context — the table «box → stroke IDs» and its digest; the
250
+ * draft goes nowhere. The consumer keeps the context, sends only the PNGs and their
251
+ * places to be checked, and gives the context back with the tutor's marks. It is the
252
252
  * sheet as it is when this is called: a stroke under way is not on it yet, while the strokes
253
253
  * under an eraser not yet lifted still are, as `filled` has them. A sheet without strokes, and a
254
254
  * workbook with no box filled, have no work to check, and the promise gives null (H3); so has a
255
- * worked example, whose sheet the learner does not write on (R42).
255
+ * worked example, whose sheet the learner does not write on.
256
256
  */
257
257
  exportWork(): Promise<ExportedWork | null>;
258
258
  /**
259
259
  * The picture of the work, for the `picture` of a stored work that app puts on the server, a
260
- * method of the agreement with app (R83; R36 spec): the PNG of the strokes the surface shows,
260
+ * method of the agreement with app: the PNG of the strokes the surface shows,
261
261
  * with no condition — the sheet's page, or the workbook's whole page with its draft, and the ink
262
- * past the page, right and down, with the tracing paper where it lies (R73): one pixel a unit,
262
+ * past the page, right and down, with the tracing paper where it lies: one pixel a unit,
263
263
  * 1000 × 1400 for the page alone, and scaled down past the page to hold no more pixels than it,
264
264
  * its size in its PNG's header —, whatever is filled and whether the work was sent to be checked
265
- * or not; an empty surface, and a worked example's, is white. The strokes are those `exportWork()` takes, as
266
- * the history has them: not the stroke under way, but those under an eraser not yet lifted. Each
267
- * is the outline the screen fills, black on white with no theme and no template — on a task from
268
- * paper the strokes of both layers, the tracing paper's where it lies, hidden or not, with the
269
- * crop's picture laid in grey and multiplied (R87) —, and the pixels
270
- * go through the crop's encoder, grey a byte each: so the picture looks as the sheet does, and
271
- * holds at most 1,576,640 bytes, for the encoder spends at most 9 bits on a byte of a row, under
272
- * the 4 MiB of a stored work.
265
+ * or not; an empty surface, and a worked example's, is white. The strokes are those
266
+ * `exportWork()` takes, as the history has them: not the stroke under way, but those under an
267
+ * eraser not yet lifted. Each is the outline the screen fills, black on white with no theme and
268
+ * no template — on a task from paper the strokes of both layers, the tracing paper's where it
269
+ * lies, hidden or not, with the crop's picture laid in grey and multiplied —, and the pixels go
270
+ * through the crop's encoder, grey a byte each: so the picture looks as the sheet does, and holds
271
+ * at most 1,576,640 bytes, for the encoder spends at most 9 bits on a byte of a row, under the 4
272
+ * MiB of a stored work.
273
273
  */
274
274
  exportPicture(): Promise<Blob>;
275
275
  disconnectedCallback(): void;