@altnovatrail/spec 0.20.1 → 0.21.1

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.
@@ -1,7 +1,7 @@
1
1
  // Code generated by tools/types from admission/schemas; DO NOT EDIT.
2
2
 
3
3
  /**
4
- * The types of the admission table, major version 0, generated from the schemas of version 0.6 in
4
+ * The types of the admission table, major version 0, generated from the schemas of version 0.7 in
5
5
  * admission/schemas by tools/types: the same types as the Go package admissionv0, by the same names
6
6
  * — the table, and the vectors of answers of the admission function. The schemas decide what is
7
7
  * valid: a type gives the shape of a value alone, and code that reads a value from elsewhere checks
@@ -113,10 +113,11 @@ export interface CapabilityRule {
113
113
  * assessment by a rubric, the hint, the words after a correct answer — the praise of a step and the
114
114
  * question of which technique helped —, voice — the voicing of the tutor by a provider and the
115
115
  * learner's voice input, which are one capability for now —, and for a task from paper the finding
116
- * of the tasks on the photo of a page, the reading of a task's statement for "Recognise", and the
117
- * Check, in which a model judges the learner's work.
116
+ * of the tasks on the photo of a page, the reading of a task's statement for "Recognise", the
117
+ * Check, in which a model judges the learner's work, and the drawing of grown-up mode, in which a
118
+ * model with none of the tutor's limits acts on the sheet as a grown-up asks.
118
119
  */
119
- export type Capability = "handwriting_reading" | "text_reading" | "solution_analysis" | "rubric_assessment" | "hint" | "correct_answer_words" | "voice" | "task_finding" | "statement_reading" | "task_checking";
120
+ export type Capability = "handwriting_reading" | "text_reading" | "solution_analysis" | "rubric_assessment" | "hint" | "correct_answer_words" | "voice" | "task_finding" | "statement_reading" | "task_checking" | "drawing";
120
121
 
121
122
  /**
122
123
  * AgeCategory is the type of admission-table.schema.json#/$defs/age_category.
package/canvas/index.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * It takes the tutor's marks of a submission too, by a property, with the submission's context:
18
18
  * their kind and their place come from the contract between app and api, novatrail.api.v1, whose
19
19
  * message `Mark` these types are checked against, and their names from app (`contracts/README.md`).
20
- * The element's members beyond this contract — its commands undo() and clear(),
20
+ * The element's members beyond this contract — its commands undo(), redo() and clear(),
21
21
  * which its own buttons call — and its place in the DOM's maps of tags and events are canvas's:
22
22
  * its package registers the element. The declarations take the DOM's
23
23
  * types: Blob, CustomEvent and HTMLElement.
@@ -28,10 +28,12 @@
28
28
  import type * as open from "../formatv0/open/index.js";
29
29
 
30
30
  /**
31
- * What a press of the primary button does on the sheet: the pen writes, the eraser erases, the hand
32
- * moves the sheet and writes nothing. A task without the eraser has the pen and the hand.
31
+ * What a press of the primary button does on the sheet: the pen writes, the eraser erases, Select
32
+ * draws a lasso or a rectangle round strokes to move, copy or delete them, the hand moves the sheet
33
+ * and writes nothing. Select and the hand are the element's own on every sheet the learner writes
34
+ * on; a task without the eraser has the pen, Select and the hand.
33
35
  */
34
- export type Tool = "pen" | "eraser" | "hand";
36
+ export type Tool = "pen" | "eraser" | "select" | "hand";
35
37
 
36
38
  /** What a `toolchange` tells: the tool the learner chose with the element's own buttons. */
37
39
  export interface ToolChange {
@@ -73,8 +75,18 @@ export type DemoChangeEvent = CustomEvent<DemoState>;
73
75
  * are the pen, the eraser and the hand.
74
76
  */
75
77
  export interface PaperTask {
76
- /** The task's crop, a JPEG or a PNG, as app cut it, without the learner's strokes. */
78
+ /**
79
+ * The task's picture, a JPEG or a PNG, without the learner's strokes: the crop app cut of the
80
+ * photo, or, for a task of a module solved on the sheet, the module's statement that app drew as
81
+ * text on white.
82
+ */
77
83
  readonly statement: Blob;
84
+ /**
85
+ * Where the picture comes from: "photo", as it is when absent, or "module". A task of a module
86
+ * shows the sign "Task of the module" above the paper and offers no "Recognise", whatever
87
+ * `reading` holds: its statement is the module's text already. Any other value is a TypeError.
88
+ */
89
+ readonly source?: "photo" | "module";
78
90
  }
79
91
 
80
92
  /**
@@ -129,8 +141,15 @@ export interface StrokeStyle {
129
141
  export type EraserMode = "stroke" | "part";
130
142
 
131
143
  /**
132
- * The learner's settings of the pen and the eraser: the kind of pen in use, each kind's own style,
133
- * which its next stroke takes, and the eraser's mode and size. An element starts with canvas's.
144
+ * The shape Select draws round the strokes it takes: "lasso", a line the pointer draws, closed from
145
+ * its end to its start; "rectangle", from where the press began to where the pointer is.
146
+ */
147
+ export type SelectShape = "lasso" | "rectangle";
148
+
149
+ /**
150
+ * The learner's settings of the pen, the eraser and Select: the kind of pen in use, each kind's own
151
+ * style, which its next stroke takes, the eraser's mode and size, and Select's shape. An element
152
+ * starts with canvas's; settings given without `select` keep the lasso.
134
153
  */
135
154
  export interface PenSettings {
136
155
  readonly pen: PenKind;
@@ -139,6 +158,7 @@ export interface PenSettings {
139
158
  readonly eraser: EraserMode;
140
159
  /** The eraser's diameter, in the sheet's units, from 1 to 200. */
141
160
  readonly eraserSize: number;
161
+ readonly select: SelectShape;
142
162
  }
143
163
 
144
164
  /**
@@ -291,10 +311,55 @@ export type HistoryEvent =
291
311
  }
292
312
  /** The sheet cleared: every stroke that was on it, in the sheet's order. */
293
313
  | { readonly kind: "clear"; readonly t: number; readonly ids: readonly number[] }
314
+ /**
315
+ * The tutor's act on the sheet in grown-up mode, one action: the strokes it wrote, new IDs in
316
+ * the order to draw them, each of the pointer's kind "tutor" with its points at the event's time
317
+ * and of no pressure, 0, and the strokes it took off, in the sheet's order. `on` is
318
+ * `"tracing"` when its strokes are on the tracing paper, as for a stroke written. The host puts
319
+ * it on the sheet by setting `history`, and an undo takes it back whole. A sample file of the
320
+ * eval protocol never holds one: the tutor's strokes are no learner's writing. A move and a copy it
321
+ * holds as an erasing of the strokes moved, if a move, and a writing of each new stroke, at the
322
+ * event's time: they replay to the same sheet.
323
+ */
324
+ | {
325
+ readonly kind: "tutor";
326
+ readonly t: number;
327
+ readonly strokes: readonly Stroke[];
328
+ readonly ids: readonly number[];
329
+ readonly on?: "tracing";
330
+ }
331
+ /**
332
+ * Strokes Select moved, one action: the strokes it took off, in the sheet's order, and the same
333
+ * strokes where the learner put them, each a new stroke after every other — the one of the same
334
+ * place in `ids` with all its points moved by one offset, its pointer's kind, style, times and
335
+ * pressures as they were. Its IDs are new, above every ID before them, ascending. `on` is
336
+ * `"tracing"` when the strokes are the tracing paper's: Select takes those of one layer. An undo
337
+ * takes it back whole.
338
+ */
339
+ | {
340
+ readonly kind: "move";
341
+ readonly t: number;
342
+ readonly ids: readonly number[];
343
+ readonly strokes: readonly Stroke[];
344
+ readonly on?: "tracing";
345
+ }
346
+ /**
347
+ * Strokes Select copied, one action: the strokes it copies, in the sheet's order, and their copies,
348
+ * new strokes after every other, as a move's are; the strokes copied stay. Select deletes by an
349
+ * `erase`.
350
+ */
351
+ | {
352
+ readonly kind: "copy";
353
+ readonly t: number;
354
+ readonly ids: readonly number[];
355
+ readonly strokes: readonly Stroke[];
356
+ readonly on?: "tracing";
357
+ }
294
358
  /**
295
359
  * The last action still in force taken back: the stroke it took off, if it was a writing, or the
296
360
  * strokes it brought back, if it was an erasing or a clearing — and of a cut, the pieces it took
297
- * off too.
361
+ * off too; of a move, the moved strokes it took off and those it brought back, and of a copy, the
362
+ * copies.
298
363
  */
299
364
  | {
300
365
  readonly kind: "undo";
@@ -315,7 +380,7 @@ export interface HistoryChange {
315
380
 
316
381
  /**
317
382
  * The event the element sends from its host, bubbling and composed, at once after every action on
318
- * the sheet: a stroke, an erasing, a cut, a clearing and an undo. Its detail is frozen. Setting `history`
383
+ * the sheet: a stroke, an erasing, a cut, a clearing, a move, a copy and an undo. Its detail is frozen. Setting `history`
319
384
  * sends none.
320
385
  */
321
386
  export type HistoryChangeEvent = CustomEvent<HistoryChange>;
@@ -447,6 +512,43 @@ export interface PaperSubmission {
447
512
  */
448
513
  export type Submission = SheetSubmission | WorkbookSubmission | PaperSubmission;
449
514
 
515
+ /**
516
+ * A stroke a crop of a task from paper shows, for the tutor in grown-up mode: its ID, and its points
517
+ * across and down in the crop's pixels, in pairs, thinned to at most 128 points, with no time and
518
+ * no pressure.
519
+ */
520
+ export interface CropStroke {
521
+ readonly id: number;
522
+ readonly points: readonly number[];
523
+ }
524
+
525
+ /**
526
+ * How far in from each side of the element the host's own controls cover the sheet — a panel over
527
+ * its right side, a bar of buttons along its foot —, in CSS pixels; a side not named is free. The
528
+ * drawing's crop of grown-up mode leaves it out, as it leaves out the element's own bar of buttons.
529
+ */
530
+ export interface DrawingCover {
531
+ readonly top?: number;
532
+ readonly right?: number;
533
+ readonly bottom?: number;
534
+ readonly left?: number;
535
+ }
536
+
537
+ /**
538
+ * The tutor's act in grown-up mode, as the drawing gave it on a crop of a task from paper: the
539
+ * strokes to write, each with its points across and down in the crop's pixels, in pairs, at least
540
+ * two points, its colour and the width of its line in the crop's pixels, and the IDs of the strokes
541
+ * to take off.
542
+ */
543
+ export interface TutorAct {
544
+ readonly strokes: readonly {
545
+ readonly points: readonly number[];
546
+ readonly color: string;
547
+ readonly width: number;
548
+ }[];
549
+ readonly erase: readonly number[];
550
+ }
551
+
450
552
  /** The work of a sheet for checking: the PNG of the crop, and the context of the submission. */
451
553
  export interface ExportedSheet {
452
554
  readonly png: Blob;
@@ -567,6 +669,32 @@ export interface Marks {
567
669
  readonly marks: readonly Mark[];
568
670
  }
569
671
 
672
+ /**
673
+ * What the element's drawing holds and has cost, for a developer's debug view of the device's load:
674
+ * a reading of counters the element keeps anyway, which no learner's data is in.
675
+ */
676
+ export interface PaintStats {
677
+ /** The finished strokes the element holds, on the sheet and on the tracing paper. */
678
+ readonly strokes: number;
679
+ /** Their points, in all. */
680
+ readonly points: number;
681
+ /** The frames the element has painted since it was built. */
682
+ readonly frames: number;
683
+ /** Of them, those that repainted all in sight: a scroll, a resize, a scale, an undo, the eraser, a theme. */
684
+ readonly fullRepaints: number;
685
+ /** The strokes filled since the element was built, on its canvas and its buffers. */
686
+ readonly fills: number;
687
+ /**
688
+ * The last frame painted: the strokes it filled, the share of the view it repainted, 0 to 1, and
689
+ * how long its painting took, in ms of `performance.now()`; `undefined` before the first.
690
+ */
691
+ readonly last: { readonly fills: number; readonly area: number; readonly ms: number } | undefined;
692
+ /** How long each of the last frames painted took, ms, oldest first: up to 120 of them. */
693
+ readonly paintMs: readonly number[];
694
+ /** Each canvas the element holds now, the screen's and its buffers', in device pixels. */
695
+ readonly buffers: readonly { readonly width: number; readonly height: number }[];
696
+ }
697
+
570
698
  /** The events of the element, by their names, for a consumer's map of events. */
571
699
  export interface CanvasEventMap {
572
700
  historychange: HistoryChangeEvent;
@@ -690,7 +818,8 @@ export interface CanvasElement extends HTMLElement {
690
818
  */
691
819
  media: Media | undefined;
692
820
  /**
693
- * The history of writing: every stroke, erasing, cut, clearing and undo on the sheet, frozen. The
821
+ * The history of writing: every stroke, erasing, cut, clearing, undo and act of the tutor on the
822
+ * sheet, frozen. The
694
823
  * consumer keeps it, adding what `historychange` tells, and gives it back to open the sheet as it
695
824
  * was. A history the sheet could not have written is a TypeError, and the sheet stays as it was;
696
825
  * `undefined` is the empty one.
@@ -729,6 +858,33 @@ export interface CanvasElement extends HTMLElement {
729
858
  * workbook with no box filled and a worked example give `null`.
730
859
  */
731
860
  exportWork(): Promise<ExportedWork | null>;
861
+ /**
862
+ * The work of a task from paper for the drawing of grown-up mode: the crop of the part of the sheet
863
+ * in sight that the grown-up sees free — the element's own bar of buttons and what `cover` names
864
+ * left out, so that the tutor writes nowhere they hide; the tracing paper where it lies, when
865
+ * shown, and every stroke there, in its style —, with room to write in, at most 1568 px on its longer edge, the task's
866
+ * crop as `exportWork()` gives it, and the context of the submission for
867
+ * `cropStrokes` and `drawTutor`. A sheet with no stroke gives it too. Without a task from paper it
868
+ * is a TypeError.
869
+ */
870
+ exportForDrawing(cover?: DrawingCover): Promise<ExportedPaper>;
871
+ /**
872
+ * The strokes the crop of a task from paper shows, by the context of the submission
873
+ * `exportWork()` or `exportForDrawing()` gave with that crop, for the tutor in grown-up mode: in the sheet's order, each
874
+ * in the crop's pixels. Another context than a task from paper's is a TypeError.
875
+ */
876
+ cropStrokes(submission: PaperSubmission): readonly CropStroke[];
877
+ /**
878
+ * The tutor's act in grown-up mode put on the sheet, by the context of the submission whose crop
879
+ * the drawing read: one `tutor` event, its strokes on the tracing paper when the context's
880
+ * tracing paper is shown, else on the sheet, of the pen kind "liner", and the strokes it takes off
881
+ * among those the sheet shows. Its strokes are drawn one after another, at the speed of a hand but
882
+ * all within 3 s, and at once with reduced motion; an undo takes the act back whole. It sends
883
+ * `historychange` at once, and resolves once the last stroke is drawn, or at once when the drawing
884
+ * is cut short. An act with an ID the sheet does not show, a point off the sheet or a colour that
885
+ * is not `#rrggbb` is a TypeError, thrown before anything changes.
886
+ */
887
+ drawTutor(submission: PaperSubmission, act: TutorAct): Promise<void>;
732
888
  /**
733
889
  * The picture of the work, which app puts as the stored work's `picture` in the contract between
734
890
  * app and api: always a Blob of a PNG, with no condition, of the strokes the surface shows as it is
@@ -737,4 +893,11 @@ export interface CanvasElement extends HTMLElement {
737
893
  * of a stored work there. Its size, in its PNG's header, is canvas's.
738
894
  */
739
895
  exportPicture(): Promise<Blob>;
896
+ /** What the drawing holds and has cost, a new frozen reading each time: for app's debug view. */
897
+ readonly paintStats: PaintStats;
898
+ /**
899
+ * While true, each rectangle a frame paints blinks red over the sheet for a moment, which no
900
+ * export holds: for app's debug view. False as an element comes.
901
+ */
902
+ paintFlash: boolean;
740
903
  }
@@ -550,8 +550,10 @@ export interface Task {
550
550
  readonly statement: Image;
551
551
  /**
552
552
  * The history of writing as the canvas gave it, the strokes of the sheet and of the tracing
553
- * paper: write/erase/cut/clear/undo events with t, a cut with the pieces it left; strokes with
554
- * id, kind, style and points x, y, t, p; on a stroke of the tracing paper, on "tracing".
553
+ * paper: write/erase/cut/clear/tutor/undo events with t, a cut with the pieces it left, a tutor
554
+ * event — the tutor's act in grown-up mode — with the strokes it wrote and the IDs it took off;
555
+ * strokes with id, kind, style and points x, y, t, p; on a stroke or a tutor event of the tracing
556
+ * paper, on "tracing".
555
557
  */
556
558
  readonly history: unknown;
557
559
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altnovatrail/spec",
3
- "version": "0.20.1",
3
+ "version": "0.21.1",
4
4
  "description": "The types of NovaTrail's module format for TypeScript, generated from its schemas: the parts of a module and their open views, the canonical view, the inventory, the module index and the test vectors. And the types of the element <novatrail-canvas>, the contract of the canvas and the app. And the types of the admission table, which says which AI provider may serve which age category. And the numbers and widths of the workbook's page and its test vectors, as JSON, by which a canvas lays the page out. And the types of the deployment configuration, the file /deployment.json that the app reads at its start. And the types of the legal texts' passport, which names each text, its versions and the sets of texts of the samples page. And the types of the table of the age of digital consent, which gives each country's age with the law that sets it. And the types of the files of an export, the file the owner of an account gets of a profile or of the account.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {