@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/element/labels.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The labels of the element's own buttons, of a workbook's boxes and of the parts of a worked
|
|
2
2
|
// example's demo, in the languages of the interface, English and Russian (R92 spec), by the shared
|
|
3
|
-
// rules of the packages' translations (R91 spec; R28, R29, R33, R36, R37, R42
|
|
3
|
+
// rules of the packages' translations (R91 spec; R28, R29, R33, R36, R37, R42):
|
|
4
4
|
// - the language is the element's own `lang`, looked up as RFC 4647 does it, and English stands for
|
|
5
5
|
// any other, under a `lang` of its own;
|
|
6
6
|
// - a label with a number or a word in it is one string with named places, «Часть {n} из {total}.»,
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
// - no label counts a thing, so none has forms of number yet. The first that does takes CLDR's
|
|
9
9
|
// categories, `other` always among them, chosen by `Intl.PluralRules` of the label's language;
|
|
10
10
|
// - no label tells the learner's gender (R70 spec) or speaks as the AI in the first person (П-15);
|
|
11
|
-
// - the buttons' words are those of
|
|
12
|
-
//
|
|
13
|
-
// sheet left the row with their buttons (R84).
|
|
11
|
+
// - the buttons' words are those of spec's table of words, the two of the page's zoom among them
|
|
12
|
+
// (R91 spec; R73); no button scrolls the sheet, so no label says a direction (R84).
|
|
14
13
|
// This module is no entry point of the package.
|
|
15
14
|
/** The labels in English, the code's own language: those of any language the table has not. */
|
|
16
15
|
const ENGLISH = Object.freeze({
|
|
@@ -74,10 +73,10 @@ const LABELS = new Map([
|
|
|
74
73
|
/** Every language the table has, by its tag: the tests hold each to English's places. */
|
|
75
74
|
export const LANGUAGES = [...LABELS.keys()];
|
|
76
75
|
/**
|
|
77
|
-
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647's
|
|
77
|
+
* Lookup does it: in lower case, cut subtag by subtag from its end until the table has what is
|
|
78
|
+
* left, a single-letter subtag going with the subtag after it. English stands for any other tag,
|
|
79
|
+
* and for none.
|
|
81
80
|
*/
|
|
82
81
|
export function labelsFor(tag) {
|
|
83
82
|
return lookup(tag) ?? { lang: "en", labels: ENGLISH };
|
|
@@ -89,7 +88,7 @@ export function labelsFor(tag) {
|
|
|
89
88
|
export function knows(tag) {
|
|
90
89
|
return lookup(tag) !== undefined;
|
|
91
90
|
}
|
|
92
|
-
/** The labels the table has for a tag, by RFC 4647
|
|
91
|
+
/** The labels the table has for a tag, by RFC 4647's Lookup, or none. */
|
|
93
92
|
function lookup(tag) {
|
|
94
93
|
let range = (tag ?? "").toLowerCase();
|
|
95
94
|
while (range !== "") {
|
|
@@ -124,7 +123,7 @@ export function say(label, values) {
|
|
|
124
123
|
}
|
|
125
124
|
/**
|
|
126
125
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
127
|
-
* and what comes after it, for a node of its own to stand between them (
|
|
126
|
+
* and what comes after it, for a node of its own to stand between them (R61). A label that names
|
|
128
127
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
129
128
|
*/
|
|
130
129
|
export function sayAround(label, place, values) {
|
package/lib/element/parts.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface Told {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* What a part that fills a box says: the box, in the labels' language, around the value the demo
|
|
12
|
-
* wrote in it, which is in the parts' own (
|
|
12
|
+
* wrote in it, which is in the parts' own (R61). Without a value the box is `before` alone.
|
|
13
13
|
*/
|
|
14
14
|
export interface FillWords {
|
|
15
15
|
/** The labels' words before the value: "Box 1.2: ". */
|
package/lib/element/parts.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// picture is, which shows the picture once the element's pictures have its file and what it shows
|
|
7
7
|
// in words till then. A picture on an area of the sheet is read by its words here, while the
|
|
8
8
|
// picture itself stands on the layer of the author's demo, stretched over its area, the later part
|
|
9
|
-
// over the earlier, and nothing stands there till its file is decoded (
|
|
9
|
+
// over the earlier, and nothing stands there till its file is decoded (R42). A box of a workbook
|
|
10
10
|
// the demo fills is read as the box, in the labels' language, and its value, a node of its own in
|
|
11
|
-
// the parts' language, which the element writes in the box itself too (
|
|
11
|
+
// the parts' language, which the element writes in the box itself too (R61). This module is
|
|
12
12
|
// no entry point of the package.
|
|
13
13
|
import { isFill, onSheet, } from "../core/example.js";
|
|
14
14
|
import { SHEET } from "../core/sheet.js";
|
|
@@ -161,9 +161,9 @@ export class Parts {
|
|
|
161
161
|
item.replaceChildren(...this.#fillNodes(part, null));
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
* What a part that fills a box says, as nodes (
|
|
165
|
-
* in their language, and the value a span of its own between them, in the language given,
|
|
166
|
-
* with none, the one it inherits.
|
|
164
|
+
* What a part that fills a box says, as nodes (R61; WCAG 3.1.2): the labels' words, each run a
|
|
165
|
+
* span in their language, and the value a span of its own between them, in the language given,
|
|
166
|
+
* or with none, the one it inherits.
|
|
167
167
|
*/
|
|
168
168
|
#fillNodes(part, valueLang) {
|
|
169
169
|
const { before, value, after, lang } = this.#fillWords(part);
|
|
@@ -176,7 +176,7 @@ export class Parts {
|
|
|
176
176
|
nodes.push(spanOf(after, lang));
|
|
177
177
|
return nodes;
|
|
178
178
|
}
|
|
179
|
-
/** An item leaving the list takes its picture off, once, and
|
|
179
|
+
/** An item leaving the list takes its picture off, once, and leaves the fills. */
|
|
180
180
|
#takeOff(item) {
|
|
181
181
|
this.#off.get(item)?.();
|
|
182
182
|
this.#off.delete(item);
|
|
@@ -219,9 +219,9 @@ export class Parts {
|
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* A picture on its area of the sheet, at the end of the layer, stretched over the area: its
|
|
222
|
-
* corners at the area's
|
|
223
|
-
* element's pictures have it decoded, and nothing till then: its words are in
|
|
224
|
-
* gives back takes the picture off the sheet.
|
|
222
|
+
* corners at the area's, as the module format's lessons place it (SVG 2). It shows its file's
|
|
223
|
+
* address once the element's pictures have it decoded, and nothing till then: its words are in
|
|
224
|
+
* its item. What it gives back takes the picture off the sheet.
|
|
225
225
|
*/
|
|
226
226
|
#onTheSheet(part) {
|
|
227
227
|
const image = document.createElementNS(SVG, "image");
|
package/lib/element/probe.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Probe {
|
|
|
10
10
|
readonly live: Stroke | undefined;
|
|
11
11
|
/** The IDs of the strokes the eraser under way has come near, or none between presses. */
|
|
12
12
|
readonly pending: readonly number[];
|
|
13
|
-
/** How many outlines of strokes the element has computed
|
|
13
|
+
/** How many outlines of strokes the element has computed since it was built. */
|
|
14
14
|
readonly outlines: number;
|
|
15
15
|
/** Where the sheet is on the screen, or nothing while the element is not laid out. */
|
|
16
16
|
readonly view: View | undefined;
|
package/lib/element/probe.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// What a test sees of an element beyond its interface: its strokes, the stroke under way, what the
|
|
2
2
|
// eraser is about to take, its view of the sheet, how many outlines it has drawn, the tutor's
|
|
3
|
-
// marks it shows and what each pointer down on it does (R29). The history of writing is
|
|
4
|
-
// element's own property
|
|
5
|
-
// element's interface stays what
|
|
6
|
-
// RUN.md, T10, T14, T15, T33, T34, T35).
|
|
3
|
+
// marks it shows and what each pointer down on it does (R29). The history of writing is not here:
|
|
4
|
+
// it is the element's own property (R27). This module is no entry point of the package, so the
|
|
5
|
+
// element's interface stays what its decisions make it (R07, R12, R19, R22, R27, R29).
|
|
7
6
|
const probes = new WeakMap();
|
|
8
7
|
/** Called by each element as it is built, with what reads its state. */
|
|
9
8
|
export function attachProbe(element, read) {
|
package/lib/element/session.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The page's pen mode (R29) and its zoom (
|
|
1
|
+
// The page's pen mode (R29) and its zoom (R73): one of each for every sheet of the page, the mode
|
|
2
2
|
// from a pen's first touch on any of them until the learner asks for the finger, the zoom as the
|
|
3
3
|
// learner last stepped it, till the page is loaded again. The next task is a new element (R20),
|
|
4
4
|
// and both stay. They are states of the interface in memory, not data: nothing is stored or sent.
|
package/lib/element/statement.js
CHANGED
|
@@ -78,7 +78,7 @@ export function framed(pictures, part) {
|
|
|
78
78
|
frame.replaceChildren(image);
|
|
79
79
|
};
|
|
80
80
|
// A browser that keeps the decoded address at hand has the picture whole at once, as
|
|
81
|
-
// Chromium does; another decodes it again, and the frame shows its words till then (
|
|
81
|
+
// Chromium does; another decodes it again, and the frame shows its words till then (R42).
|
|
82
82
|
if (image.complete && image.naturalWidth > 0) {
|
|
83
83
|
swap();
|
|
84
84
|
return;
|
package/lib/element/tools.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class Tools {
|
|
|
65
65
|
* The bar as the sheet now is. Only what has changed is written. A worked example's has no tools
|
|
66
66
|
* of writing, no undo and no clearing, for the learner does not write on its sheet, and its row
|
|
67
67
|
* has Next, unavailable while the demo is hidden or open whole, and Demo, expanded while the demo
|
|
68
|
-
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (
|
|
68
|
+
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (R73). The tool in use
|
|
69
69
|
* shows its icon filled, and Demo's icon points down while the demo is shown, and along the row
|
|
70
70
|
* while it is hidden (R46).
|
|
71
71
|
*/
|
package/lib/element/tools.js
CHANGED
|
@@ -6,23 +6,21 @@
|
|
|
6
6
|
// one. Undo and Clear with nothing to take back or to clear stay where the focus can reach them,
|
|
7
7
|
// marked unavailable: a last undo from the keyboard leaves the focus where it was. Zoom in and Zoom
|
|
8
8
|
// out step the page's zoom of the sheet, from its fit to twice it, each unavailable at its end
|
|
9
|
-
// (
|
|
10
|
-
// scroll it: a hand drags it, the wheel and the keys scroll it (R84;
|
|
11
|
-
// amendment to R90 spec).
|
|
9
|
+
// (R73). In pen mode a last button lets a finger write again (R29). The sheet has no buttons that
|
|
10
|
+
// scroll it: a hand drags it, the wheel and the keys scroll it (R84; R90 spec).
|
|
12
11
|
// The buttons of the bar show an icon alone, of the set every NovaTrail package of the interface
|
|
13
12
|
// draws from (R46; R78 spec): each is named by its label, in the element's language (labels.ts),
|
|
14
13
|
// which only a screen reader reads, and shows it in a tooltip of its own on the pointer's hover and
|
|
15
|
-
// on the keyboard's focus, which Escape dismisses and the pointer can move onto (
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// the first button shown. This module is no entry point of the package.
|
|
14
|
+
// on the keyboard's focus, which Escape dismisses and the pointer can move onto (R90 spec; WCAG
|
|
15
|
+
// 1.4.13). The bar is named by the canvas kind's buttons: the sheet's or the workbook's (R36), for
|
|
16
|
+
// the kind's own name is the scroll container's (R28). A lesson's worked example names it too, and
|
|
17
|
+
// has no tools of writing: the learner does not write on its sheet, and its bar holds the zoom's
|
|
18
|
+
// pair alone. Its demo's buttons, Next, which opens the next part, and Demo, a disclosure button
|
|
19
|
+
// that hides the whole demo and shows it again, are actions, not tools (R42; R90 spec): each shows
|
|
20
|
+
// its label beside its icon, a stop of Tab of its own, in a row of glass at the bottom of the
|
|
21
|
+
// element, and after a line the slot `actions`, where the consumer puts its own buttons — app's
|
|
22
|
+
// Continue —, as the mockup has one row (R84; R36 spec). A button that goes gives its stop of Tab
|
|
23
|
+
// and the focus to the first button shown. This module is no entry point of the package.
|
|
26
24
|
import { SVG, write } from "./attributes.js";
|
|
27
25
|
import { ICONS, ROW } from "./icons.js";
|
|
28
26
|
import { labelsFor } from "./labels.js";
|
|
@@ -209,7 +207,7 @@ export class Tools {
|
|
|
209
207
|
* The bar as the sheet now is. Only what has changed is written. A worked example's has no tools
|
|
210
208
|
* of writing, no undo and no clearing, for the learner does not write on its sheet, and its row
|
|
211
209
|
* has Next, unavailable while the demo is hidden or open whole, and Demo, expanded while the demo
|
|
212
|
-
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (
|
|
210
|
+
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (R73). The tool in use
|
|
213
211
|
* shows its icon filled, and Demo's icon points down while the demo is shown, and along the row
|
|
214
212
|
* while it is hidden (R46).
|
|
215
213
|
*/
|
|
@@ -407,7 +405,7 @@ export class Tools {
|
|
|
407
405
|
#shown() {
|
|
408
406
|
return this.#buttons.filter((button) => !button.hidden);
|
|
409
407
|
}
|
|
410
|
-
/** The first button the bar shows: Zoom in and Zoom out are on every bar (
|
|
408
|
+
/** The first button the bar shows: Zoom in and Zoom out are on every bar (R73). */
|
|
411
409
|
#first() {
|
|
412
410
|
return this.#shown()[0] ?? this.#zoomIn;
|
|
413
411
|
}
|
|
@@ -420,8 +418,8 @@ export class Tools {
|
|
|
420
418
|
/**
|
|
421
419
|
* Glass that scrolls inside itself — the bar down, a worked example's row across — brings what has
|
|
422
420
|
* the focus wholly into its view, within its padding, as the first button and the last stand at its
|
|
423
|
-
* ends (2.4.11): Firefox's focus() leaves one in sight in part where it is, and so do all
|
|
424
|
-
* engines in a row. The glass alone scrolls, not what scrolls the element.
|
|
421
|
+
* ends (WCAG 2.4.11): Firefox's focus() leaves one in sight in part where it is, and so do all
|
|
422
|
+
* three engines in a row. The glass alone scrolls, not what scrolls the element.
|
|
425
423
|
*/
|
|
426
424
|
function bringIn(glass, item) {
|
|
427
425
|
const outer = glass.getBoundingClientRect();
|