@altnovatrail/canvas 0.3.32 → 0.3.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/boxes.d.ts +1 -1
- package/lib/core/boxes.js +3 -3
- package/lib/core/crop.d.ts +1 -5
- package/lib/core/crop.js +1 -5
- package/lib/core/example.js +2 -2
- package/lib/core/grid.d.ts +3 -6
- package/lib/core/grid.js +2 -2
- package/lib/core/groups.d.ts +1 -1
- package/lib/core/groups.js +1 -1
- package/lib/core/hands.d.ts +7 -7
- package/lib/core/hands.js +6 -6
- package/lib/core/history.d.ts +3 -2
- package/lib/core/history.js +3 -2
- package/lib/core/index.js +2 -2
- package/lib/core/manifest.d.ts +2 -3
- package/lib/core/manifest.js +2 -3
- package/lib/core/marks.d.ts +3 -3
- package/lib/core/marks.js +3 -4
- package/lib/core/page.d.ts +2 -2
- package/lib/core/page.js +6 -6
- package/lib/core/recorder.d.ts +5 -5
- package/lib/core/recorder.js +5 -5
- package/lib/core/screen.d.ts +7 -8
- package/lib/core/screen.js +4 -4
- package/lib/core/submission.d.ts +2 -2
- package/lib/core/submission.js +2 -2
- package/lib/core/task.d.ts +6 -7
- package/lib/core/task.js +1 -1
- package/lib/core/zoom.d.ts +2 -2
- package/lib/core/zoom.js +2 -2
- package/lib/element/icons.d.ts +1 -1
- package/lib/element/icons.js +2 -2
- package/lib/element/index.d.ts +28 -30
- package/lib/element/index.js +125 -123
- package/lib/element/labels.d.ts +7 -7
- package/lib/element/labels.js +9 -10
- package/lib/element/parts.d.ts +1 -1
- package/lib/element/parts.js +9 -9
- package/lib/element/probe.d.ts +1 -1
- package/lib/element/probe.js +3 -4
- package/lib/element/session.js +1 -1
- package/lib/element/statement.js +1 -1
- package/lib/element/tools.d.ts +1 -1
- package/lib/element/tools.js +16 -18
- package/package.json +1 -1
package/lib/core/boxes.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface BoxRule {
|
|
|
16
16
|
readonly margin: number;
|
|
17
17
|
readonly limit: number;
|
|
18
18
|
}
|
|
19
|
-
/** The rule the workbook has (R37)
|
|
19
|
+
/** The rule the workbook has (R37). */
|
|
20
20
|
export declare const BOX_RULE: BoxRule;
|
|
21
21
|
/**
|
|
22
22
|
* Which answer slots the learner's strokes fill, per item, per slot, in the task's order: a
|
package/lib/core/boxes.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// widened by 120 thousandths of its size — 12 units of a box of 100, short of the 16 to halfway to
|
|
5
5
|
// the next box — and it is no wider and no taller than the box and 30 units on each side: a
|
|
6
6
|
// fraction's bar wider than the box is its own, and a line through the whole line is not. The
|
|
7
|
-
// core's entry point does not give the rule. It is the eval protocol's
|
|
8
|
-
//
|
|
7
|
+
// core's entry point does not give the rule. It is the eval protocol's too, and spec's test vectors
|
|
8
|
+
// pin it (R94 spec).
|
|
9
9
|
import { extentOf, tenths } from "./geometry.js";
|
|
10
|
-
/** The rule the workbook has (R37)
|
|
10
|
+
/** The rule the workbook has (R37). */
|
|
11
11
|
export const BOX_RULE = Object.freeze({ margin: 120, limit: 1600 });
|
|
12
12
|
/** A sheet's one answer slot, filled and not: the same frozen arrays for every sheet (R42). */
|
|
13
13
|
const STROKED = Object.freeze([Object.freeze([true])]);
|
package/lib/core/crop.d.ts
CHANGED
|
@@ -26,10 +26,7 @@ export declare const CROP: Readonly<{
|
|
|
26
26
|
edge: 1568;
|
|
27
27
|
tokens: 1568;
|
|
28
28
|
patch: 28;
|
|
29
|
-
/**
|
|
30
|
-
* The height of a digit a crop is drawn at unless the module's manifest says another, px: 24
|
|
31
|
-
* since the module format 0.2, with or without a manifest.
|
|
32
|
-
*/
|
|
29
|
+
/** The height of a digit a crop is drawn at, px, unless a module's manifest names another. */
|
|
33
30
|
digit: 24;
|
|
34
31
|
/**
|
|
35
32
|
* The heights of digits a sample's crops are drawn at, px, as the eval protocol names them,
|
|
@@ -59,7 +56,6 @@ export interface Crop extends CropNumbers {
|
|
|
59
56
|
/** The width of the line, px: D′ / 12, and 1 at least. */
|
|
60
57
|
readonly line: number;
|
|
61
58
|
}
|
|
62
|
-
/** A stroke as the crop sees it: the box of its points in tenths. */
|
|
63
59
|
/**
|
|
64
60
|
* The bundles of the strokes on a sheet (R25): strokes no lower than `CROP.flat`, joined by a chain
|
|
65
61
|
* of boxes that touch or overlap, whenever each was written. Each bundle by its IDs ascending, the
|
package/lib/core/crop.js
CHANGED
|
@@ -26,10 +26,7 @@ export const CROP = Object.freeze({
|
|
|
26
26
|
edge: 1568,
|
|
27
27
|
tokens: 1568,
|
|
28
28
|
patch: 28,
|
|
29
|
-
/**
|
|
30
|
-
* The height of a digit a crop is drawn at unless the module's manifest says another, px: 24
|
|
31
|
-
* since the module format 0.2, with or without a manifest.
|
|
32
|
-
*/
|
|
29
|
+
/** The height of a digit a crop is drawn at, px, unless a module's manifest names another. */
|
|
33
30
|
digit: 24,
|
|
34
31
|
/**
|
|
35
32
|
* The heights of digits a sample's crops are drawn at, px, as the eval protocol names them,
|
|
@@ -39,7 +36,6 @@ export const CROP = Object.freeze({
|
|
|
39
36
|
/** The tallest digit a crop takes, px: its ink then still stays within the margin. */
|
|
40
37
|
tallest: 256,
|
|
41
38
|
});
|
|
42
|
-
/** A stroke as the crop sees it: the box of its points in tenths. */
|
|
43
39
|
/**
|
|
44
40
|
* The bundles of the strokes on a sheet (R25): strokes no lower than `CROP.flat`, joined by a chain
|
|
45
41
|
* of boxes that touch or overlap, whenever each was written. Each bundle by its IDs ascending, the
|
package/lib/core/example.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// A lesson's worked example (R58 spec; R42): the open view of a segment `worked_example`, of spec's
|
|
2
2
|
// type WorkedExample (R73 spec; R41) — its statement, the handwriting sheet or the workbook the
|
|
3
3
|
// author's demo is shown on, and the demo's parts in order: paragraphs, pictures beside the sheet,
|
|
4
|
-
// pictures on areas of a sheet, and on a workbook the boxes it fills (format 0.4;
|
|
4
|
+
// pictures on areas of a sheet, and on a workbook the boxes it fills (format 0.4; R61). The
|
|
5
5
|
// element checks it as the schema does, every object closed (R32), and by the format's rules
|
|
6
6
|
// lesson.areas, lesson.example-fills and lesson.workbook-page too: an area lies on the sheet, the
|
|
7
7
|
// demo fills each box of the lines once, and the lines fit the page, each value its box. What the
|
|
@@ -137,7 +137,7 @@ function sameLine(a, b) {
|
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* What a worked example is shown on: a handwriting sheet and its grid, or a workbook, and no tools,
|
|
140
|
-
* for the learner does not write on it (
|
|
140
|
+
* for the learner does not write on it (R42).
|
|
141
141
|
*/
|
|
142
142
|
function exampleCanvasOf(value, path) {
|
|
143
143
|
const canvas = closed(value, path, ["kind", "grid", "grid_step"], "a worked example's canvas");
|
package/lib/core/grid.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a task rules the sheet (concepts 8 spec): in squares, in lines or in dots, as concepts 16.1
|
|
3
|
-
* spec's illustration names them.
|
|
4
|
-
*/
|
|
1
|
+
/** How a task rules the sheet: in squares, in lines or in dots. */
|
|
5
2
|
export type GridKind = "squares" | "lines" | "dots";
|
|
6
3
|
/** The grid of a sheet: its kind and its step, in sheet units. */
|
|
7
4
|
export interface Grid {
|
|
@@ -18,8 +15,8 @@ export declare const GRID_STEP = 50;
|
|
|
18
15
|
export declare const GRID_STEP_MIN = 20;
|
|
19
16
|
export declare const GRID_STEP_MAX = 500;
|
|
20
17
|
/**
|
|
21
|
-
* The grid of a sheet whose task gives none, or that has no task: squares of 50 units.
|
|
22
|
-
*
|
|
18
|
+
* The grid of a sheet whose task gives none, or that has no task: squares of 50 units. spec knows
|
|
19
|
+
* no sheet without a grid (R23).
|
|
23
20
|
*/
|
|
24
21
|
export declare const DEFAULT_GRID: Grid;
|
|
25
22
|
/**
|
package/lib/core/grid.js
CHANGED
|
@@ -9,8 +9,8 @@ export const GRID_STEP = 50;
|
|
|
9
9
|
export const GRID_STEP_MIN = 20;
|
|
10
10
|
export const GRID_STEP_MAX = 500;
|
|
11
11
|
/**
|
|
12
|
-
* The grid of a sheet whose task gives none, or that has no task: squares of 50 units.
|
|
13
|
-
*
|
|
12
|
+
* The grid of a sheet whose task gives none, or that has no task: squares of 50 units. spec knows
|
|
13
|
+
* no sheet without a grid (R23).
|
|
14
14
|
*/
|
|
15
15
|
export const DEFAULT_GRID = Object.freeze({ kind: "squares", step: GRID_STEP });
|
|
16
16
|
/**
|
package/lib/core/groups.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare function neighboursOf(strokes: readonly Stroke[], rule?: GroupRul
|
|
|
45
45
|
/**
|
|
46
46
|
* The rectangle of a group on the sheet: the box around the points of its strokes, in sheet units,
|
|
47
47
|
* of the geometry it is given — the raw strokes on the device, the recorded ones in a sample (R09).
|
|
48
|
-
* Its box in the fractions of a cut-out is the cut-out's
|
|
48
|
+
* Its box in the fractions of a cut-out is the cut-out's.
|
|
49
49
|
*/
|
|
50
50
|
export declare function rectOf(ids: readonly number[], strokes: readonly Stroke[]): Box;
|
|
51
51
|
/**
|
package/lib/core/groups.js
CHANGED
|
@@ -44,7 +44,7 @@ export function neighboursOf(strokes, rule = GROUP_RULE) {
|
|
|
44
44
|
/**
|
|
45
45
|
* The rectangle of a group on the sheet: the box around the points of its strokes, in sheet units,
|
|
46
46
|
* of the geometry it is given — the raw strokes on the device, the recorded ones in a sample (R09).
|
|
47
|
-
* Its box in the fractions of a cut-out is the cut-out's
|
|
47
|
+
* Its box in the fractions of a cut-out is the cut-out's.
|
|
48
48
|
*/
|
|
49
49
|
export function rectOf(ids, strokes) {
|
|
50
50
|
const wanted = new Set(ids);
|
package/lib/core/hands.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface Contact {
|
|
|
24
24
|
/**
|
|
25
25
|
* A touch wider or taller than this, in CSS pixels, is a palm (R29). 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
|
-
* take most fingers there for palms.
|
|
27
|
+
* take most fingers there for palms. No tablet has measured it.
|
|
28
28
|
*/
|
|
29
29
|
export declare const PALM_PX = 100;
|
|
30
30
|
/**
|
|
@@ -40,9 +40,9 @@ export declare const PAIR_MS = 150;
|
|
|
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 (
|
|
43
|
+
* they pass the slop, scroll along that axis alone for the rest of the gesture (R73): a scroll
|
|
44
44
|
* down a zoomed sheet does not wander sideways, nor one across it up and down. Between, they go
|
|
45
|
-
* both ways.
|
|
45
|
+
* both ways.
|
|
46
46
|
*/
|
|
47
47
|
export declare const RAIL = 2;
|
|
48
48
|
/**
|
|
@@ -82,8 +82,8 @@ export interface HandsSheet {
|
|
|
82
82
|
*/
|
|
83
83
|
scroll(dx: number, dy: number, fresh: boolean): void;
|
|
84
84
|
/**
|
|
85
|
-
* Whether the sheet scrolls across at all now: a zoomed sheet does (
|
|
86
|
-
* that does not goes by its travel down alone
|
|
85
|
+
* Whether the sheet scrolls across at all now: a zoomed sheet does (R73). A gesture on a sheet
|
|
86
|
+
* that does not goes by its travel down alone.
|
|
87
87
|
*/
|
|
88
88
|
across(): boolean;
|
|
89
89
|
}
|
|
@@ -100,7 +100,7 @@ export type Role = "writes" | "waits" | "scrolls" | "palm" | "idle";
|
|
|
100
100
|
/**
|
|
101
101
|
* The hands on a sheet (R29): which pointer may write, which is a palm, and which two fingers
|
|
102
102
|
* scroll, for a pen, fingers and a mouse on one screen.
|
|
103
|
-
* - One pointer writes at a time
|
|
103
|
+
* - One pointer writes at a time (R18), and the sheet's recorder and eraser say which.
|
|
104
104
|
* - A pen's touch puts the page in pen mode and takes away the stroke of a touch under way: it was
|
|
105
105
|
* a palm. While a pen or a mouse writes, a touch does nothing until it lifts.
|
|
106
106
|
* - A touch wider or taller than `PALM_PX`, at its `pointerdown` or at any move, is a palm: it does
|
|
@@ -110,7 +110,7 @@ export type Role = "writes" | "waits" | "scrolls" | "palm" | "idle";
|
|
|
110
110
|
* comes later does nothing.
|
|
111
111
|
* - In pen mode a finger writes nothing, and two that come down within `PAIR_MS` scroll. One that
|
|
112
112
|
* goes further than `SLOP_PX` alone, before a second comes, drags the sheet: the second does
|
|
113
|
-
* nothing then (R84;
|
|
113
|
+
* nothing then (R84; R90 spec).
|
|
114
114
|
* - A third finger does nothing. When one of the two lifts, the other does nothing until it lifts.
|
|
115
115
|
* - Two fingers scroll by the travel of their middle on the screen, and one by its own, past its
|
|
116
116
|
* first `SLOP_PX`: along one axis alone if it went `RAIL` times further along it than along the
|
package/lib/core/hands.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A touch wider or taller than this, in CSS pixels, is a palm (R29). 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
|
-
* take most fingers there for palms.
|
|
4
|
+
* take most fingers there for palms. No tablet has measured it.
|
|
5
5
|
*/
|
|
6
6
|
export const PALM_PX = 100;
|
|
7
7
|
/**
|
|
@@ -17,9 +17,9 @@ export const PAIR_MS = 150;
|
|
|
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 (
|
|
20
|
+
* they pass the slop, scroll along that axis alone for the rest of the gesture (R73): a scroll
|
|
21
21
|
* down a zoomed sheet does not wander sideways, nor one across it up and down. Between, they go
|
|
22
|
-
* both ways.
|
|
22
|
+
* both ways.
|
|
23
23
|
*/
|
|
24
24
|
export const RAIL = 2;
|
|
25
25
|
/**
|
|
@@ -81,7 +81,7 @@ export class PenMode {
|
|
|
81
81
|
/**
|
|
82
82
|
* The hands on a sheet (R29): which pointer may write, which is a palm, and which two fingers
|
|
83
83
|
* scroll, for a pen, fingers and a mouse on one screen.
|
|
84
|
-
* - One pointer writes at a time
|
|
84
|
+
* - One pointer writes at a time (R18), and the sheet's recorder and eraser say which.
|
|
85
85
|
* - A pen's touch puts the page in pen mode and takes away the stroke of a touch under way: it was
|
|
86
86
|
* a palm. While a pen or a mouse writes, a touch does nothing until it lifts.
|
|
87
87
|
* - A touch wider or taller than `PALM_PX`, at its `pointerdown` or at any move, is a palm: it does
|
|
@@ -91,7 +91,7 @@ export class PenMode {
|
|
|
91
91
|
* comes later does nothing.
|
|
92
92
|
* - In pen mode a finger writes nothing, and two that come down within `PAIR_MS` scroll. One that
|
|
93
93
|
* goes further than `SLOP_PX` alone, before a second comes, drags the sheet: the second does
|
|
94
|
-
* nothing then (R84;
|
|
94
|
+
* nothing then (R84; R90 spec).
|
|
95
95
|
* - A third finger does nothing. When one of the two lifts, the other does nothing until it lifts.
|
|
96
96
|
* - Two fingers scroll by the travel of their middle on the screen, and one by its own, past its
|
|
97
97
|
* first `SLOP_PX`: along one axis alone if it went `RAIL` times further along it than along the
|
|
@@ -293,7 +293,7 @@ export class Hands {
|
|
|
293
293
|
return;
|
|
294
294
|
const middle = middleOf(one, two);
|
|
295
295
|
if (gesture.last === undefined) {
|
|
296
|
-
// A sheet that does not scroll across counts the travel down alone
|
|
296
|
+
// A sheet that does not scroll across counts the travel down alone.
|
|
297
297
|
const dx = this.#sheet.across() ? middle.x - gesture.from.x : 0;
|
|
298
298
|
const dy = middle.y - gesture.from.y;
|
|
299
299
|
const gone = Math.hypot(dx, dy);
|
package/lib/core/history.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ export declare function replay(history: readonly HistoryEvent[]): Stroke[];
|
|
|
20
20
|
* the four, at a time from 0 that never goes back along the history; a stroke must have a new ID, a
|
|
21
21
|
* whole number from 1, and one point at least, each on the sheet, with a pressure from 0 to 1, its
|
|
22
22
|
* times never going back and none after the time it landed. Times are checked for their order
|
|
23
|
-
* alone:
|
|
24
|
-
* the rules of the stack, the work on the sheet checks as it replays them
|
|
23
|
+
* alone: strokes may overlap in time, as several pointers at once would write them. Whether the
|
|
24
|
+
* actions keep the rules of the stack, the work on the sheet checks as it replays them
|
|
25
|
+
* (`Work.restore`).
|
|
25
26
|
*/
|
|
26
27
|
export declare function historyOf(value: unknown): HistoryEvent[];
|
|
27
28
|
/**
|
package/lib/core/history.js
CHANGED
|
@@ -35,8 +35,9 @@ export function replay(history) {
|
|
|
35
35
|
* the four, at a time from 0 that never goes back along the history; a stroke must have a new ID, a
|
|
36
36
|
* whole number from 1, and one point at least, each on the sheet, with a pressure from 0 to 1, its
|
|
37
37
|
* times never going back and none after the time it landed. Times are checked for their order
|
|
38
|
-
* alone:
|
|
39
|
-
* the rules of the stack, the work on the sheet checks as it replays them
|
|
38
|
+
* alone: strokes may overlap in time, as several pointers at once would write them. Whether the
|
|
39
|
+
* actions keep the rules of the stack, the work on the sheet checks as it replays them
|
|
40
|
+
* (`Work.restore`).
|
|
40
41
|
*/
|
|
41
42
|
export function historyOf(value) {
|
|
42
43
|
if (!Array.isArray(value))
|
package/lib/core/index.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// and the fold of a history into the strokes it leaves, so that a consumer
|
|
9
9
|
// reads a history it keeps without the DOM (R27). The code runs without the DOM, but spec's
|
|
10
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 (
|
|
11
|
+
// consumer without the DOM's types skips them with skipLibCheck (R27). The rules of the groups, the
|
|
12
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
|
|
13
|
+
// vectors pin them (R94 spec).
|
|
14
14
|
export { replay } from "./history.js";
|
|
15
15
|
export { SHEET } from "./sheet.js";
|
package/lib/core/manifest.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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
|
|
4
|
-
*
|
|
5
|
-
* api's: the element compares none (R32).
|
|
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).
|
|
6
5
|
*/
|
|
7
6
|
export declare const FORMAT = "0.4";
|
|
8
7
|
/** The open view of a module's manifest, whole: spec's type (R73 spec). */
|
package/lib/core/manifest.js
CHANGED
|
@@ -10,9 +10,8 @@ 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
|
|
14
|
-
*
|
|
15
|
-
* api's: the element compares none (R32).
|
|
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).
|
|
16
15
|
*/
|
|
17
16
|
export const FORMAT = "0.4";
|
|
18
17
|
/** The settings without a manifest: digits of 24 px, and the element's own language. */
|
package/lib/core/marks.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare const SNAP_RULE: SnapRule;
|
|
|
40
40
|
* its place names it, its item and its place among the item's cells, each from 1 (R51 spec).
|
|
41
41
|
*
|
|
42
42
|
* The tutor's marks of one submission, with the submission's context, are spec's types too, of the
|
|
43
|
-
* same contract (
|
|
43
|
+
* same contract (R74 spec; R83 spec): a mark is a frame, with where it is and the name a screen
|
|
44
44
|
* reader gives it, in the consumer's words — the element words nothing. Where it is: a group of
|
|
45
45
|
* strokes by its label, an answer cell by its place, or a box on the crop the model saw,
|
|
46
46
|
* [ymin, xmin, ymax, xmax] in whole thousandths of its height and width, min < max (R53 spec). On a
|
|
@@ -87,8 +87,8 @@ export declare function snapOf(box: readonly [number, number, number, number], c
|
|
|
87
87
|
* box's the strokes it snaps to; an answer cell's holds none on a sheet, which takes no zones.
|
|
88
88
|
* `cells` are the boxes of a workbook's page, in the task's order, and null on a sheet: there a
|
|
89
89
|
* cell's mark holds the strokes of its row of the table, with its box; one of a box not in the
|
|
90
|
-
* table, an empty one, holds its box alone, and one of a box not on the page holds none (R39;
|
|
91
|
-
*
|
|
90
|
+
* table, an empty one, holds its box alone, and one of a box not on the page holds none (R39;
|
|
91
|
+
* R74 spec).
|
|
92
92
|
*
|
|
93
93
|
* A submission of other strokes is a TypeError: a stroke of its groups the sheet does not know, or
|
|
94
94
|
* a digest the sheet's strokes of those IDs do not give with the submission's numbers (R27). A
|
package/lib/core/marks.js
CHANGED
|
@@ -75,8 +75,8 @@ export function snapOf(box, crop, strokes, rule = SNAP_RULE) {
|
|
|
75
75
|
* box's the strokes it snaps to; an answer cell's holds none on a sheet, which takes no zones.
|
|
76
76
|
* `cells` are the boxes of a workbook's page, in the task's order, and null on a sheet: there a
|
|
77
77
|
* cell's mark holds the strokes of its row of the table, with its box; one of a box not in the
|
|
78
|
-
* table, an empty one, holds its box alone, and one of a box not on the page holds none (R39;
|
|
79
|
-
*
|
|
78
|
+
* table, an empty one, holds its box alone, and one of a box not on the page holds none (R39;
|
|
79
|
+
* R74 spec).
|
|
80
80
|
*
|
|
81
81
|
* A submission of other strokes is a TypeError: a stroke of its groups the sheet does not know, or
|
|
82
82
|
* a digest the sheet's strokes of those IDs do not give with the submission's numbers (R27). A
|
|
@@ -180,8 +180,7 @@ function cellsPlacesOf(marks, { boxes, digest }, byId, cells) {
|
|
|
180
180
|
return null;
|
|
181
181
|
const { left, top, width, height } = cell.box;
|
|
182
182
|
const frame = { minX: left, minY: top, maxX: left + width, maxY: top + height };
|
|
183
|
-
// A box the submission found empty is framed alone (
|
|
184
|
-
// spec; R39).
|
|
183
|
+
// A box the submission found empty is framed alone (R39; R74 spec).
|
|
185
184
|
if (row === undefined)
|
|
186
185
|
return { ids: [], box: frame, cell: frame };
|
|
187
186
|
return {
|
package/lib/core/page.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface Layout {
|
|
|
21
21
|
/** The margin of the page on its sides, its top and its bottom. */
|
|
22
22
|
readonly margin: number;
|
|
23
23
|
}
|
|
24
|
-
/** The layout the workbook has
|
|
24
|
+
/** The layout the workbook has: a sweep chose it around the box the author chose (R35). */
|
|
25
25
|
export declare const LAYOUT: Layout;
|
|
26
26
|
/** A piece of a line's text, or its part on one line of the page: one `<text>` (R34, R35). */
|
|
27
27
|
export interface PageText {
|
|
@@ -67,7 +67,7 @@ export declare function isBox(part: PageText | PageBox): part is PageBox;
|
|
|
67
67
|
/**
|
|
68
68
|
* The width of a text as one piece on one line, in whole units: its words and the spaces between
|
|
69
69
|
* them, as the layout measures a fragment of a piece (R35). A worked example's value is held to its
|
|
70
|
-
* box's width by it (
|
|
70
|
+
* box's width by it (the format's rule lesson.workbook-page; R60), and drawn at it.
|
|
71
71
|
*/
|
|
72
72
|
export declare function pieceWidth(text: string, layout?: Layout): number;
|
|
73
73
|
/**
|
package/lib/core/page.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
// device: the widths of the text come from the canvas's own table (widths.ts), and SVG fits the
|
|
5
5
|
// text to them. Short lines stand two to a row, in the task's order; a long line takes the page's
|
|
6
6
|
// width and wraps. A task whose lines do not fit is a TypeError: nothing shrinks. The numbers and
|
|
7
|
-
// the rule are the format's
|
|
8
|
-
// @altnovatrail/spec carries and the tests hold the layout to (
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// the rule are the module format's, its page.yaml and its test vectors, which the npm package
|
|
8
|
+
// @altnovatrail/spec carries and the tests hold the layout to (R60; R51 spec): they change only
|
|
9
|
+
// with the format, for histories know neither the task nor the layout (R34). The core's entry
|
|
10
|
+
// point does not give the layout.
|
|
11
11
|
import { SHEET } from "./sheet.js";
|
|
12
12
|
import { clustersOf, clusterWidth, SPACE, wordsOf, wordWidth } from "./widths.js";
|
|
13
|
-
/** The layout the workbook has
|
|
13
|
+
/** The layout the workbook has: a sweep chose it around the box the author chose (R35). */
|
|
14
14
|
export const LAYOUT = Object.freeze({
|
|
15
15
|
size: 30,
|
|
16
16
|
boxWidth: 100,
|
|
@@ -51,7 +51,7 @@ function measuresOf(layout) {
|
|
|
51
51
|
/**
|
|
52
52
|
* The width of a text as one piece on one line, in whole units: its words and the spaces between
|
|
53
53
|
* them, as the layout measures a fragment of a piece (R35). A worked example's value is held to its
|
|
54
|
-
* box's width by it (
|
|
54
|
+
* box's width by it (the format's rule lesson.workbook-page; R60), and drawn at it.
|
|
55
55
|
*/
|
|
56
56
|
export function pieceWidth(text, layout = LAYOUT) {
|
|
57
57
|
const words = wordsOf(text);
|
package/lib/core/recorder.d.ts
CHANGED
|
@@ -32,11 +32,11 @@ export declare const PRIMARY = 0;
|
|
|
32
32
|
/** The primary button's bit in `buttons`. */
|
|
33
33
|
export declare const PRIMARY_HELD = 1;
|
|
34
34
|
/**
|
|
35
|
-
* The strokes of one sheet, from the pointer's samples (R18
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* The strokes of one sheet, from the pointer's samples (R18). One pointer writes at a time, with
|
|
36
|
+
* its primary button: a second pointer, and any other button, write nothing while a stroke is
|
|
37
|
+
* under way. A finished stroke goes to the handler the recorder is made with — onto the work on
|
|
38
|
+
* the sheet (R19). Its points take their time from the sheet's clock, which the sheet's other
|
|
39
|
+
* actions keep too (R22).
|
|
40
40
|
*/
|
|
41
41
|
export declare class Recorder {
|
|
42
42
|
#private;
|
package/lib/core/recorder.js
CHANGED
|
@@ -10,11 +10,11 @@ export const PRIMARY = 0;
|
|
|
10
10
|
/** The primary button's bit in `buttons`. */
|
|
11
11
|
export const PRIMARY_HELD = 1;
|
|
12
12
|
/**
|
|
13
|
-
* The strokes of one sheet, from the pointer's samples (R18
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* The strokes of one sheet, from the pointer's samples (R18). One pointer writes at a time, with
|
|
14
|
+
* its primary button: a second pointer, and any other button, write nothing while a stroke is
|
|
15
|
+
* under way. A finished stroke goes to the handler the recorder is made with — onto the work on
|
|
16
|
+
* the sheet (R19). Its points take their time from the sheet's clock, which the sheet's other
|
|
17
|
+
* actions keep too (R22).
|
|
18
18
|
*/
|
|
19
19
|
export class Recorder {
|
|
20
20
|
#finished;
|
package/lib/core/screen.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where the sheet is on the screen, one view for every layer (R06
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* in units (T94).
|
|
2
|
+
* Where the sheet is on the screen, one view for every layer (R06): `k` CSS pixels to a logical
|
|
3
|
+
* unit, for the sheet fits the width of its area times the page's zoom, and `vx` and `vy`, the left
|
|
4
|
+
* and the top of the sheet's visible part, in units (R73).
|
|
6
5
|
*/
|
|
7
6
|
export interface View {
|
|
8
7
|
readonly k: number;
|
|
@@ -17,21 +16,21 @@ export interface Point {
|
|
|
17
16
|
/**
|
|
18
17
|
* The most CSS pixels to a unit of the sheet's fit: on a wide screen the sheet fits at most 1000
|
|
19
18
|
* CSS pixels wide, a pixel to a unit as on the picture of the work, and stands in the middle (R23).
|
|
20
|
-
* The page's zoom takes it beyond that, to twice the fit (
|
|
19
|
+
* The page's zoom takes it beyond that, to twice the fit (R73).
|
|
21
20
|
*/
|
|
22
21
|
export declare const K_MAX = 1;
|
|
23
22
|
/** `k` of a sheet `width` CSS pixels wide as it is on the screen: k = A / W. */
|
|
24
23
|
export declare function scaleFor(width: number): number;
|
|
25
24
|
/**
|
|
26
25
|
* `k` for a sheet laid out in an area `width` CSS pixels wide: it fits the width, up to `K_MAX`,
|
|
27
|
-
* times the page's `zoom` (
|
|
26
|
+
* times the page's `zoom` (R73). This is the layout's `k`, before any transform the page puts on
|
|
28
27
|
* the element; input takes `k` from the sheet's rectangle on the screen, by `scaleFor`.
|
|
29
28
|
*/
|
|
30
29
|
export declare function fitScale(width: number, zoom?: number): number;
|
|
31
30
|
/**
|
|
32
31
|
* The point of the sheet under a point of the screen, given in CSS pixels from the top left corner
|
|
33
|
-
* of the sheet's visible part. A point beyond the sheet is clamped to its edge
|
|
34
|
-
*
|
|
32
|
+
* of the sheet's visible part. A point beyond the sheet is clamped to its edge: a pointer captured
|
|
33
|
+
* by the sheet goes on writing on its edge.
|
|
35
34
|
*/
|
|
36
35
|
export declare function toSheet(view: View, x: number, y: number): Point;
|
|
37
36
|
/** The point of the screen over a point of the sheet, from the top left corner of its visible part. */
|
package/lib/core/screen.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SHEET } from "./sheet.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The most CSS pixels to a unit of the sheet's fit: on a wide screen the sheet fits at most 1000
|
|
4
4
|
* CSS pixels wide, a pixel to a unit as on the picture of the work, and stands in the middle (R23).
|
|
5
|
-
* The page's zoom takes it beyond that, to twice the fit (
|
|
5
|
+
* The page's zoom takes it beyond that, to twice the fit (R73).
|
|
6
6
|
*/
|
|
7
7
|
export const K_MAX = 1;
|
|
8
8
|
/** `k` of a sheet `width` CSS pixels wide as it is on the screen: k = A / W. */
|
|
@@ -11,7 +11,7 @@ export function scaleFor(width) {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* `k` for a sheet laid out in an area `width` CSS pixels wide: it fits the width, up to `K_MAX`,
|
|
14
|
-
* times the page's `zoom` (
|
|
14
|
+
* times the page's `zoom` (R73). This is the layout's `k`, before any transform the page puts on
|
|
15
15
|
* the element; input takes `k` from the sheet's rectangle on the screen, by `scaleFor`.
|
|
16
16
|
*/
|
|
17
17
|
export function fitScale(width, zoom = 1) {
|
|
@@ -19,8 +19,8 @@ export function fitScale(width, zoom = 1) {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* The point of the sheet under a point of the screen, given in CSS pixels from the top left corner
|
|
22
|
-
* of the sheet's visible part. A point beyond the sheet is clamped to its edge
|
|
23
|
-
*
|
|
22
|
+
* of the sheet's visible part. A point beyond the sheet is clamped to its edge: a pointer captured
|
|
23
|
+
* by the sheet goes on writing on its edge.
|
|
24
24
|
*/
|
|
25
25
|
export function toSheet(view, x, y) {
|
|
26
26
|
return {
|
package/lib/core/submission.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare function workForCheck(strokes: readonly Stroke[], digit: number):
|
|
|
35
35
|
* with its item and its slot, in the task's order, and the context of the submission: the table and
|
|
36
36
|
* its digest. The draft goes nowhere. A page with no box filled has no work to check, and gives
|
|
37
37
|
* null, though it holds draft. The crops are frozen, not their bytes, which no freezing holds; the
|
|
38
|
-
* context is frozen through. One crop of every box's strokes, which spec may choose
|
|
39
|
-
*
|
|
38
|
+
* context is frozen through. One crop of every box's strokes, which spec may choose, is
|
|
39
|
+
* `croppedOf` of the table's strokes with the table's rows for groups (R38).
|
|
40
40
|
*/
|
|
41
41
|
export declare function cellsForCheck(strokes: readonly Stroke[], cells: readonly Cell[], digit: number): CellsForCheck | null;
|
package/lib/core/submission.js
CHANGED
|
@@ -27,8 +27,8 @@ export function workForCheck(strokes, digit) {
|
|
|
27
27
|
* with its item and its slot, in the task's order, and the context of the submission: the table and
|
|
28
28
|
* its digest. The draft goes nowhere. A page with no box filled has no work to check, and gives
|
|
29
29
|
* null, though it holds draft. The crops are frozen, not their bytes, which no freezing holds; the
|
|
30
|
-
* context is frozen through. One crop of every box's strokes, which spec may choose
|
|
31
|
-
*
|
|
30
|
+
* context is frozen through. One crop of every box's strokes, which spec may choose, is
|
|
31
|
+
* `croppedOf` of the table's strokes with the table's rows for groups (R38).
|
|
32
32
|
*/
|
|
33
33
|
export function cellsForCheck(strokes, cells, digit) {
|
|
34
34
|
const boxes = tableOf(strokes, cells);
|
package/lib/core/task.d.ts
CHANGED
|
@@ -74,11 +74,10 @@ export interface SheetCanvas {
|
|
|
74
74
|
/** The grid's step in sheet units, a whole number from 20 to 500: 50 unless given. */
|
|
75
75
|
readonly grid_step?: number;
|
|
76
76
|
/**
|
|
77
|
-
* The tools the task allows (
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* with it.
|
|
77
|
+
* The tools the task allows (R28), the element's own field until the format has one: the canvas
|
|
78
|
+
* takes "pen" and "eraser", and passes over the names it does not know — a ruler, a calculator —
|
|
79
|
+
* which are app's to show or come with new versions of the canvas. The pen and the eraser unless
|
|
80
|
+
* given; a list without the pen is a TypeError, for the canvas writes with it.
|
|
82
81
|
*/
|
|
83
82
|
readonly tools?: readonly string[];
|
|
84
83
|
}
|
|
@@ -88,8 +87,8 @@ export interface WorkbookCanvas {
|
|
|
88
87
|
readonly tools?: readonly string[];
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
91
|
-
* The canvas of a task as a consumer gives it: spec's, and the tools the task allows (
|
|
92
|
-
*
|
|
90
|
+
* The canvas of a task as a consumer gives it: spec's, and the tools the task allows (R28), the
|
|
91
|
+
* element's own field until the format has one.
|
|
93
92
|
*/
|
|
94
93
|
export interface Canvas extends open.Canvas {
|
|
95
94
|
readonly tools?: readonly string[];
|
package/lib/core/task.js
CHANGED
|
@@ -43,7 +43,7 @@ export function taskOf(value) {
|
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* What the statement gives and what the task asks to find, as the task has them: the element checks
|
|
46
|
-
* them and shows neither, for the chips are app's to show (
|
|
46
|
+
* them and shows neither, for the chips are app's to show (R57 spec).
|
|
47
47
|
*/
|
|
48
48
|
function askedOf({ givens, unknown, }) {
|
|
49
49
|
return {
|
package/lib/core/zoom.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The zooms of the sheet, from its fit to twice it, by quarters (
|
|
2
|
+
* The zooms of the sheet, from its fit to twice it, by quarters (R73): the learner steps through
|
|
3
3
|
* them with the row's Zoom in and Zoom out, so that the workbook's printed lines, and the ink, can
|
|
4
4
|
* be read at 200 % (WCAG 1.4.4, by the technique G178; R90 spec).
|
|
5
5
|
*/
|
|
6
6
|
export declare const ZOOMS: readonly number[];
|
|
7
7
|
/**
|
|
8
|
-
* The page's zoom (
|
|
8
|
+
* The page's zoom (R73): one for every sheet of the page, from 100 % when the page is loaded, as
|
|
9
9
|
* the pen mode is (R29). The next task is a new element (R20), and the zoom stays: a learner who
|
|
10
10
|
* needs it larger asks once. It lives in memory alone: nothing is stored or sent.
|
|
11
11
|
*/
|
package/lib/core/zoom.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The zooms of the sheet, from its fit to twice it, by quarters (
|
|
2
|
+
* The zooms of the sheet, from its fit to twice it, by quarters (R73): the learner steps through
|
|
3
3
|
* them with the row's Zoom in and Zoom out, so that the workbook's printed lines, and the ink, can
|
|
4
4
|
* be read at 200 % (WCAG 1.4.4, by the technique G178; R90 spec).
|
|
5
5
|
*/
|
|
6
6
|
export const ZOOMS = [1, 1.25, 1.5, 1.75, 2];
|
|
7
7
|
/**
|
|
8
|
-
* The page's zoom (
|
|
8
|
+
* The page's zoom (R73): one for every sheet of the page, from 100 % when the page is loaded, as
|
|
9
9
|
* the pen mode is (R29). The next task is a new element (R20), and the zoom stays: a learner who
|
|
10
10
|
* needs it larger asks once. It lives in memory alone: nothing is stored or sent.
|
|
11
11
|
*/
|
package/lib/element/icons.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type IconName = keyof typeof ICONS;
|
|
|
54
54
|
/**
|
|
55
55
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
56
56
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
57
|
-
* runs right to left (
|
|
57
|
+
* runs right to left (R78 spec).
|
|
58
58
|
*/
|
|
59
59
|
export declare const ROW: {
|
|
60
60
|
readonly next: {
|
package/lib/element/icons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Written by scripts/icons.ts — `just icons` — from @iconify-json/material-symbols 1.2.99:
|
|
2
|
-
// Material Symbols by Google, under the Apache License 2.0 (R46
|
|
2
|
+
// Material Symbols by Google, under the Apache License 2.0 (R46; R78 spec).
|
|
3
3
|
// ci-lint fails unless it is what the script writes, so it is never edited by hand. This module is
|
|
4
4
|
// no entry point of the package.
|
|
5
5
|
/** The icons of the row's buttons, by their names in the set, as the element draws them. */
|
|
@@ -80,7 +80,7 @@ export const ICONS = {
|
|
|
80
80
|
/**
|
|
81
81
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
82
82
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
83
|
-
* runs right to left (
|
|
83
|
+
* runs right to left (R78 spec).
|
|
84
84
|
*/
|
|
85
85
|
export const ROW = {
|
|
86
86
|
next: {
|