@altnovatrail/spec 0.20.0 → 0.21.0

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
@@ -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 {
@@ -129,8 +131,15 @@ export interface StrokeStyle {
129
131
  export type EraserMode = "stroke" | "part";
130
132
 
131
133
  /**
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.
134
+ * The shape Select draws round the strokes it takes: "lasso", a line the pointer draws, closed from
135
+ * its end to its start; "rectangle", from where the press began to where the pointer is.
136
+ */
137
+ export type SelectShape = "lasso" | "rectangle";
138
+
139
+ /**
140
+ * The learner's settings of the pen, the eraser and Select: the kind of pen in use, each kind's own
141
+ * style, which its next stroke takes, the eraser's mode and size, and Select's shape. An element
142
+ * starts with canvas's; settings given without `select` keep the lasso.
134
143
  */
135
144
  export interface PenSettings {
136
145
  readonly pen: PenKind;
@@ -139,6 +148,7 @@ export interface PenSettings {
139
148
  readonly eraser: EraserMode;
140
149
  /** The eraser's diameter, in the sheet's units, from 1 to 200. */
141
150
  readonly eraserSize: number;
151
+ readonly select: SelectShape;
142
152
  }
143
153
 
144
154
  /**
@@ -291,10 +301,55 @@ export type HistoryEvent =
291
301
  }
292
302
  /** The sheet cleared: every stroke that was on it, in the sheet's order. */
293
303
  | { readonly kind: "clear"; readonly t: number; readonly ids: readonly number[] }
304
+ /**
305
+ * The tutor's act on the sheet in grown-up mode, one action: the strokes it wrote, new IDs in
306
+ * the order to draw them, each of the pointer's kind "tutor" with its points at the event's time
307
+ * and of no pressure, 0, and the strokes it took off, in the sheet's order. `on` is
308
+ * `"tracing"` when its strokes are on the tracing paper, as for a stroke written. The host puts
309
+ * it on the sheet by setting `history`, and an undo takes it back whole. A sample file of the
310
+ * eval protocol never holds one: the tutor's strokes are no learner's writing. A move and a copy it
311
+ * holds as an erasing of the strokes moved, if a move, and a writing of each new stroke, at the
312
+ * event's time: they replay to the same sheet.
313
+ */
314
+ | {
315
+ readonly kind: "tutor";
316
+ readonly t: number;
317
+ readonly strokes: readonly Stroke[];
318
+ readonly ids: readonly number[];
319
+ readonly on?: "tracing";
320
+ }
321
+ /**
322
+ * Strokes Select moved, one action: the strokes it took off, in the sheet's order, and the same
323
+ * strokes where the learner put them, each a new stroke after every other — the one of the same
324
+ * place in `ids` with all its points moved by one offset, its pointer's kind, style, times and
325
+ * pressures as they were. Its IDs are new, above every ID before them, ascending. `on` is
326
+ * `"tracing"` when the strokes are the tracing paper's: Select takes those of one layer. An undo
327
+ * takes it back whole.
328
+ */
329
+ | {
330
+ readonly kind: "move";
331
+ readonly t: number;
332
+ readonly ids: readonly number[];
333
+ readonly strokes: readonly Stroke[];
334
+ readonly on?: "tracing";
335
+ }
336
+ /**
337
+ * Strokes Select copied, one action: the strokes it copies, in the sheet's order, and their copies,
338
+ * new strokes after every other, as a move's are; the strokes copied stay. Select deletes by an
339
+ * `erase`.
340
+ */
341
+ | {
342
+ readonly kind: "copy";
343
+ readonly t: number;
344
+ readonly ids: readonly number[];
345
+ readonly strokes: readonly Stroke[];
346
+ readonly on?: "tracing";
347
+ }
294
348
  /**
295
349
  * The last action still in force taken back: the stroke it took off, if it was a writing, or the
296
350
  * strokes it brought back, if it was an erasing or a clearing — and of a cut, the pieces it took
297
- * off too.
351
+ * off too; of a move, the moved strokes it took off and those it brought back, and of a copy, the
352
+ * copies.
298
353
  */
299
354
  | {
300
355
  readonly kind: "undo";
@@ -315,7 +370,7 @@ export interface HistoryChange {
315
370
 
316
371
  /**
317
372
  * 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`
373
+ * the sheet: a stroke, an erasing, a cut, a clearing, a move, a copy and an undo. Its detail is frozen. Setting `history`
319
374
  * sends none.
320
375
  */
321
376
  export type HistoryChangeEvent = CustomEvent<HistoryChange>;
@@ -447,6 +502,43 @@ export interface PaperSubmission {
447
502
  */
448
503
  export type Submission = SheetSubmission | WorkbookSubmission | PaperSubmission;
449
504
 
505
+ /**
506
+ * A stroke a crop of a task from paper shows, for the tutor in grown-up mode: its ID, and its points
507
+ * across and down in the crop's pixels, in pairs, thinned to at most 128 points, with no time and
508
+ * no pressure.
509
+ */
510
+ export interface CropStroke {
511
+ readonly id: number;
512
+ readonly points: readonly number[];
513
+ }
514
+
515
+ /**
516
+ * How far in from each side of the element the host's own controls cover the sheet — a panel over
517
+ * its right side, a bar of buttons along its foot —, in CSS pixels; a side not named is free. The
518
+ * drawing's crop of grown-up mode leaves it out, as it leaves out the element's own bar of buttons.
519
+ */
520
+ export interface DrawingCover {
521
+ readonly top?: number;
522
+ readonly right?: number;
523
+ readonly bottom?: number;
524
+ readonly left?: number;
525
+ }
526
+
527
+ /**
528
+ * The tutor's act in grown-up mode, as the drawing gave it on a crop of a task from paper: the
529
+ * strokes to write, each with its points across and down in the crop's pixels, in pairs, at least
530
+ * two points, its colour and the width of its line in the crop's pixels, and the IDs of the strokes
531
+ * to take off.
532
+ */
533
+ export interface TutorAct {
534
+ readonly strokes: readonly {
535
+ readonly points: readonly number[];
536
+ readonly color: string;
537
+ readonly width: number;
538
+ }[];
539
+ readonly erase: readonly number[];
540
+ }
541
+
450
542
  /** The work of a sheet for checking: the PNG of the crop, and the context of the submission. */
451
543
  export interface ExportedSheet {
452
544
  readonly png: Blob;
@@ -567,6 +659,32 @@ export interface Marks {
567
659
  readonly marks: readonly Mark[];
568
660
  }
569
661
 
662
+ /**
663
+ * What the element's drawing holds and has cost, for a developer's debug view of the device's load:
664
+ * a reading of counters the element keeps anyway, which no learner's data is in.
665
+ */
666
+ export interface PaintStats {
667
+ /** The finished strokes the element holds, on the sheet and on the tracing paper. */
668
+ readonly strokes: number;
669
+ /** Their points, in all. */
670
+ readonly points: number;
671
+ /** The frames the element has painted since it was built. */
672
+ readonly frames: number;
673
+ /** Of them, those that repainted all in sight: a scroll, a resize, a scale, an undo, the eraser, a theme. */
674
+ readonly fullRepaints: number;
675
+ /** The strokes filled since the element was built, on its canvas and its buffers. */
676
+ readonly fills: number;
677
+ /**
678
+ * The last frame painted: the strokes it filled, the share of the view it repainted, 0 to 1, and
679
+ * how long its painting took, in ms of `performance.now()`; `undefined` before the first.
680
+ */
681
+ readonly last: { readonly fills: number; readonly area: number; readonly ms: number } | undefined;
682
+ /** How long each of the last frames painted took, ms, oldest first: up to 120 of them. */
683
+ readonly paintMs: readonly number[];
684
+ /** Each canvas the element holds now, the screen's and its buffers', in device pixels. */
685
+ readonly buffers: readonly { readonly width: number; readonly height: number }[];
686
+ }
687
+
570
688
  /** The events of the element, by their names, for a consumer's map of events. */
571
689
  export interface CanvasEventMap {
572
690
  historychange: HistoryChangeEvent;
@@ -690,7 +808,8 @@ export interface CanvasElement extends HTMLElement {
690
808
  */
691
809
  media: Media | undefined;
692
810
  /**
693
- * The history of writing: every stroke, erasing, cut, clearing and undo on the sheet, frozen. The
811
+ * The history of writing: every stroke, erasing, cut, clearing, undo and act of the tutor on the
812
+ * sheet, frozen. The
694
813
  * consumer keeps it, adding what `historychange` tells, and gives it back to open the sheet as it
695
814
  * was. A history the sheet could not have written is a TypeError, and the sheet stays as it was;
696
815
  * `undefined` is the empty one.
@@ -729,6 +848,33 @@ export interface CanvasElement extends HTMLElement {
729
848
  * workbook with no box filled and a worked example give `null`.
730
849
  */
731
850
  exportWork(): Promise<ExportedWork | null>;
851
+ /**
852
+ * The work of a task from paper for the drawing of grown-up mode: the crop of the part of the sheet
853
+ * in sight that the grown-up sees free — the element's own bar of buttons and what `cover` names
854
+ * left out, so that the tutor writes nowhere they hide; the tracing paper where it lies, when
855
+ * shown, and every stroke there, in its style —, with room to write in, at most 1568 px on its longer edge, the task's
856
+ * crop as `exportWork()` gives it, and the context of the submission for
857
+ * `cropStrokes` and `drawTutor`. A sheet with no stroke gives it too. Without a task from paper it
858
+ * is a TypeError.
859
+ */
860
+ exportForDrawing(cover?: DrawingCover): Promise<ExportedPaper>;
861
+ /**
862
+ * The strokes the crop of a task from paper shows, by the context of the submission
863
+ * `exportWork()` or `exportForDrawing()` gave with that crop, for the tutor in grown-up mode: in the sheet's order, each
864
+ * in the crop's pixels. Another context than a task from paper's is a TypeError.
865
+ */
866
+ cropStrokes(submission: PaperSubmission): readonly CropStroke[];
867
+ /**
868
+ * The tutor's act in grown-up mode put on the sheet, by the context of the submission whose crop
869
+ * the drawing read: one `tutor` event, its strokes on the tracing paper when the context's
870
+ * tracing paper is shown, else on the sheet, of the pen kind "liner", and the strokes it takes off
871
+ * among those the sheet shows. Its strokes are drawn one after another, at the speed of a hand but
872
+ * all within 3 s, and at once with reduced motion; an undo takes the act back whole. It sends
873
+ * `historychange` at once, and resolves once the last stroke is drawn, or at once when the drawing
874
+ * is cut short. An act with an ID the sheet does not show, a point off the sheet or a colour that
875
+ * is not `#rrggbb` is a TypeError, thrown before anything changes.
876
+ */
877
+ drawTutor(submission: PaperSubmission, act: TutorAct): Promise<void>;
732
878
  /**
733
879
  * The picture of the work, which app puts as the stored work's `picture` in the contract between
734
880
  * app and api: always a Blob of a PNG, with no condition, of the strokes the surface shows as it is
@@ -737,4 +883,11 @@ export interface CanvasElement extends HTMLElement {
737
883
  * of a stored work there. Its size, in its PNG's header, is canvas's.
738
884
  */
739
885
  exportPicture(): Promise<Blob>;
886
+ /** What the drawing holds and has cost, a new frozen reading each time: for app's debug view. */
887
+ readonly paintStats: PaintStats;
888
+ /**
889
+ * While true, each rectangle a frame paints blinks red over the sheet for a moment, which no
890
+ * export holds: for app's debug view. False as an element comes.
891
+ */
892
+ paintFlash: boolean;
740
893
  }
@@ -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.0",
3
+ "version": "0.21.0",
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": {