@altnovatrail/spec 0.5.7 → 0.6.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.
package/README.md CHANGED
@@ -29,8 +29,9 @@ function show(task: open.Task, manifest: open.Manifest) {
29
29
  A field the object always holds is required, and any other is optional. That includes each field that only some branches of a schema give.
30
30
  - **`@altnovatrail/spec/formatv0/open`** holds the open view of each part, which is what the learner's app gets ([the format's text](https://github.com/altnovatrail/spec/blob/main/format/README.md#6-open-fields), section 6). Each type keeps its name from `formatv0` and only the fields marked `x-open`, so an open view has no check, no template and no solver.
31
31
  - **`@altnovatrail/spec/canvas`** holds the types of `<novatrail-canvas>`:
32
- - `CanvasElement`, which describes the element's properties `tool`, `task`, `manifest`, `history` and `filled` and its method `exportWork()`;
33
- - the events `toolchange` and `historychange`, with `CanvasEventMap` naming them;
32
+ - `CanvasElement`, which describes the element's properties `tool`, `task`, `workedExample`, `demoState`, `manifest`, `history` and `filled` and its method `exportWork()`;
33
+ - the events `toolchange`, `historychange` and `demochange`, with `CanvasEventMap` naming them;
34
+ - the state of a worked example's demo, `DemoState`;
34
35
  - the history of writing;
35
36
  - the work for checking, with the context of its submission.
36
37
 
package/canvas/index.d.ts CHANGED
@@ -4,8 +4,10 @@
4
4
  /**
5
5
  * The types of the element `<novatrail-canvas>`: the contract of canvas and app (R36). The element
6
6
  * takes a task and its module's manifest, and the learner's history of writing, by properties; it
7
- * gives the work for checking by a method, and tells what the learner did by events. The types of
8
- * the task and of the manifest are the module format's open views, formatv0/open.
7
+ * gives the work for checking by a method, and tells what the learner did by events. In place of a
8
+ * task it may show a lesson's worked example, whose demo the learner opens part by part with its
9
+ * buttons, and how far they have gone is a property and an event too. The types of the task, of
10
+ * the worked example and of the manifest are the module format's open views, formatv0/open.
9
11
  *
10
12
  * The tutor's marks — the property `marks` and the types of a mark — wait for the contract of epic
11
13
  * E3, and are canvas's own until then. The element's members beyond this contract, and its place in
@@ -35,6 +37,26 @@ export interface ToolChange {
35
37
  */
36
38
  export type ToolChangeEvent = CustomEvent<ToolChange>;
37
39
 
40
+ /**
41
+ * How far the learner has gone through a worked example's demo: how many of its parts are open,
42
+ * from the first, and whether the whole demo is hidden. Every demo starts at
43
+ * `{ opened: 0, hidden: false }`.
44
+ */
45
+ export interface DemoState {
46
+ /** How many parts of the demo are open, from the first: from 0 to all of them. */
47
+ readonly opened: number;
48
+ /** Whether the whole demo is hidden: its open parts stay open, out of sight. */
49
+ readonly hidden: boolean;
50
+ }
51
+
52
+ /**
53
+ * The event the element sends from its host, bubbling and composed, when the learner opens the
54
+ * next part of the demo, or hides or shows the whole demo, with its buttons — not when the consumer
55
+ * sets `demoState`, nor when a new worked example starts its demo at the beginning. Its detail is
56
+ * the new state, frozen.
57
+ */
58
+ export type DemoChangeEvent = CustomEvent<DemoState>;
59
+
38
60
  /**
39
61
  * A point of a stroke: where it lies on the sheet, in its logical units, when it was written and
40
62
  * how hard the pointer pressed.
@@ -121,8 +143,9 @@ export interface CellPlace {
121
143
  }
122
144
 
123
145
  /**
124
- * Which boxes of a workbook are filled: per item, per box, in the task's order, whether the box
125
- * holds one of the strokes `exportWork()` would take.
146
+ * Which answer slots the learner's strokes fill: per item, per slot, in the task's order, whether
147
+ * the slot holds one of the strokes `exportWork()` would take. On a workbook a slot is a box; on a
148
+ * sheet it is the task's one slot bound `anywhere` or `sheet`, and the sheet holds the strokes.
126
149
  */
127
150
  export type Filled = readonly (readonly boolean[])[];
128
151
 
@@ -245,6 +268,7 @@ export type ExportedWork = ExportedSheet | ExportedWorkbook;
245
268
  export interface CanvasEventMap {
246
269
  historychange: HistoryChangeEvent;
247
270
  toolchange: ToolChangeEvent;
271
+ demochange: DemoChangeEvent;
248
272
  }
249
273
 
250
274
  /**
@@ -257,12 +281,37 @@ export interface CanvasElement extends HTMLElement {
257
281
  * which a `toolchange` tells; the consumer may set it too, which tells nothing.
258
282
  */
259
283
  tool: Tool;
260
- /** The open view of the task, given before the history and the marks. */
284
+ /**
285
+ * The open view of the task, given before the history and the marks. The element shows a task
286
+ * or a worked example, not both: a task given while it shows an example is a TypeError, and so is
287
+ * a task with an answer slot bound `zone`, which no module of the first slice takes.
288
+ */
261
289
  task: open.Task | undefined;
262
290
  /**
263
- * The open view of the task's module's manifest. The element reads its version of the module
264
- * format, the height of a digit on the crop for checking, `canvas.digit_height`, and its
265
- * explanation language. A canvas setting it does not know is a TypeError.
291
+ * The open view of a lesson's worked example, its segment `worked_example`, in place of a task;
292
+ * its module's manifest is `manifest`, as a task's is. The element shows the example's statement
293
+ * and its sheet, which the learner does not write on: the sheet takes no input, and the tool is the
294
+ * pen alone, so an eraser is a TypeError. An example given while the element shows a task, or has
295
+ * a history of writing, is a TypeError; while it shows one, so are a task, a history other than
296
+ * the empty one and the marks, and `filled` and `exportWork()` give `null`. app gives each segment
297
+ * of a lesson a new element. On one element, a task comes once the example is `undefined`, and
298
+ * another example starts its demo at the beginning.
299
+ */
300
+ workedExample: open.WorkedExample | undefined;
301
+ /**
302
+ * How far the learner has gone through the worked example's demo, frozen: `undefined` without an
303
+ * example, and `{ opened: 0, hidden: false }` as a new one starts. The learner changes it with the
304
+ * element's buttons, which a `demochange` tells; the consumer keeps it and may give it back,
305
+ * which tells nothing. Given before an example, a state is a TypeError, and so is one the demo
306
+ * cannot have, such as more parts open than it has; `undefined` changes nothing.
307
+ */
308
+ get demoState(): DemoState | undefined;
309
+ set demoState(state: DemoState | undefined);
310
+ /**
311
+ * The open view of the manifest of the module of the task or of the worked example. The element
312
+ * reads its version of the module format, the height of a digit on the crop for checking,
313
+ * `canvas.digit_height`, and its explanation language. A canvas setting it does not know is a
314
+ * TypeError.
266
315
  */
267
316
  manifest: open.Manifest | undefined;
268
317
  /**
@@ -274,14 +323,16 @@ export interface CanvasElement extends HTMLElement {
274
323
  get history(): readonly HistoryEvent[];
275
324
  set history(history: readonly HistoryEvent[] | undefined);
276
325
  /**
277
- * Which boxes of a workbook are filled, frozen; `null` on a sheet. An action on the sheet changes
278
- * it before its `historychange`, and a task or a history given changes it with no event.
326
+ * Which answer slots are filled, frozen: a workbook's boxes, and on a sheet the task's one slot
327
+ * bound `anywhere` or `sheet`. `null` on a sheet whose slots are bound `choice`, whose options app
328
+ * marks, on a sheet with no task, and for a worked example. An action on the sheet changes it
329
+ * before its `historychange`, and a task or a history given changes it with no event.
279
330
  */
280
331
  readonly filled: Filled | null;
281
332
  /**
282
333
  * The work for checking, as the sheet is when it is called: a sheet's crop or a workbook's boxes,
283
- * with the context of the submission. A sheet without strokes, and a workbook with no box filled,
284
- * give `null`.
334
+ * with the context of the submission. A sheet without strokes, a workbook with no box filled and a
335
+ * worked example give `null`.
285
336
  */
286
337
  exportWork(): Promise<ExportedWork | null>;
287
338
  }
@@ -1,7 +1,7 @@
1
1
  // Code generated by tools/types from format/schemas; DO NOT EDIT.
2
2
 
3
3
  /**
4
- * The types of the module format, major version 0, generated from the schemas of version 0.1 in
4
+ * The types of the module format, major version 0, generated from the schemas of version 0.2 in
5
5
  * format/schemas by tools/types (R72 and R73 in spec's docs/decisions.md): the same types as the Go
6
6
  * package formatv0, by the same names. The schemas decide what is valid: a type gives the shape of
7
7
  * a value alone, and code that reads a value from elsewhere checks it against its schema first. A
@@ -95,7 +95,7 @@ export type Numbers = Readonly<Record<TemplateName, number>>;
95
95
  */
96
96
  export interface Manifest {
97
97
  /**
98
- * The version of the module format the module is written in, "0.1": the module is checked, built
98
+ * The version of the module format the module is written in, "0.2": the module is checked, built
99
99
  * and run by it. It stands at the root of the manifest in every version of the format, so that a
100
100
  * reader finds it before it knows which schemas to read the module by.
101
101
  */
@@ -221,9 +221,9 @@ export interface Languages {
221
221
  export interface CanvasSettings {
222
222
  /**
223
223
  * The height in px that a digit or a letter of the learner's writing has on the crop that goes to
224
- * be read: 32 unless given.
224
+ * be read: 24 unless given.
225
225
  *
226
- * @defaultValue 32
226
+ * @defaultValue 24
227
227
  */
228
228
  readonly digit_height?: number;
229
229
  }
@@ -243,7 +243,7 @@ export interface Author {
243
243
  /**
244
244
  * ModuleFormatVersion is the type of common.schema.json#/$defs/module_format_version.
245
245
  *
246
- * A version of the module format, MAJOR.MINOR, written as a string: "0.1".
246
+ * A version of the module format, MAJOR.MINOR, written as a string: "0.2".
247
247
  */
248
248
  export type ModuleFormatVersion = string;
249
249
 
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * The open view of each part of a module (format/README.md, section 6): the type of each struct the
5
5
  * open view of a part reaches, by the name it has in formatv0, with the fields marked x-open alone,
6
- * of version 0.1. An open view has no check, no template and no solver; a task's has its givens and
6
+ * of version 0.2. An open view has no check, no template and no solver; a task's has its givens and
7
7
  * its unknown. Strings, integers and enumerations are formatv0's.
8
8
  *
9
9
  * @packageDocumentation
@@ -25,7 +25,7 @@ import type * as formatv0 from "../index.js";
25
25
  */
26
26
  export interface Manifest {
27
27
  /**
28
- * The version of the module format the module is written in, "0.1": the module is checked, built
28
+ * The version of the module format the module is written in, "0.2": the module is checked, built
29
29
  * and run by it. It stands at the root of the manifest in every version of the format, so that a
30
30
  * reader finds it before it knows which schemas to read the module by.
31
31
  */
@@ -155,9 +155,9 @@ export interface Languages {
155
155
  export interface CanvasSettings {
156
156
  /**
157
157
  * The height in px that a digit or a letter of the learner's writing has on the crop that goes to
158
- * be read: 32 unless given.
158
+ * be read: 24 unless given.
159
159
  *
160
- * @defaultValue 32
160
+ * @defaultValue 24
161
161
  */
162
162
  readonly digit_height?: number;
163
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altnovatrail/spec",
3
- "version": "0.5.7",
3
+ "version": "0.6.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.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {