@mechane-ai/elements 0.47.0 → 0.48.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.
Files changed (204) hide show
  1. package/README.md +288 -5
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/article-BXZr10QQ.js +1904 -0
  4. package/dist/article.js +1 -0
  5. package/dist/catalog.json +1389 -75
  6. package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
  7. package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
  8. package/dist/charts/cartesian.js +1 -1
  9. package/dist/charts/cells.js +1 -1
  10. package/dist/charts/comparison.js +1 -1
  11. package/dist/charts/distribution.js +1 -1
  12. package/dist/charts/figure.js +12 -12
  13. package/dist/charts/graph.js +1 -1
  14. package/dist/charts/hierarchy.js +1 -1
  15. package/dist/charts/image.js +1 -1
  16. package/dist/charts/matrix.js +3 -2
  17. package/dist/charts/plot.js +4 -4
  18. package/dist/charts/relationship.js +1 -1
  19. package/dist/charts/text.js +1 -1
  20. package/dist/charts/timeline.js +1 -1
  21. package/dist/charts/trend.js +1 -1
  22. package/dist/charts.js +2 -2
  23. package/dist/clock-DSm5lkNE.js +16 -0
  24. package/dist/collections.js +1 -1
  25. package/dist/describe-lesson-BmREzDpt.js +175 -0
  26. package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
  27. package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
  28. package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
  29. package/dist/forms.js +1 -1
  30. package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
  31. package/dist/kits/evaluation.js +5 -5
  32. package/dist/kits/interpretability.js +9 -9
  33. package/dist/kits/operations.js +4 -4
  34. package/dist/kits/training.js +4 -4
  35. package/dist/lesson/agent.js +811 -0
  36. package/dist/lesson/spec.js +661 -0
  37. package/dist/lesson.js +5 -0
  38. package/dist/mdx.js +227 -0
  39. package/dist/packages/charts/src/matrix/index.d.ts +1 -0
  40. package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
  41. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  42. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  43. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  44. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  45. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  46. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  47. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  48. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  49. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  50. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  51. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  52. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  53. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  54. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  55. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  56. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  57. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  58. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  59. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  60. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  61. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  62. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  63. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  64. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  65. package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
  66. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  67. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  68. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  69. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  70. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  71. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  72. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  73. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  74. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  75. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  76. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  77. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  78. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  79. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  80. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  81. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  82. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  83. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  84. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  85. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  86. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  87. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  88. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  89. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  90. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  91. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  92. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  93. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  94. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  95. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  96. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  97. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  98. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  99. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  100. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  101. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  102. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  103. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  104. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  105. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  106. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  107. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  108. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  109. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  110. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  111. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  112. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  113. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  114. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  115. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  116. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  117. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  118. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  119. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  120. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  121. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  122. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  123. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  124. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  125. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  126. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  127. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  128. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  129. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  130. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  131. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  132. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  133. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  134. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  135. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  136. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  137. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  138. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  139. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  140. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  141. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  142. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  143. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  144. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  145. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  146. package/dist/param-CqKUTHaO.js +450 -0
  147. package/dist/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
  148. package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
  149. package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
  150. package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
  151. package/dist/scene-0z2gbaDE.js +4938 -0
  152. package/dist/scene.js +1 -0
  153. package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
  154. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  155. package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
  156. package/dist/styles2.css +475 -18
  157. package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
  158. package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
  159. package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
  160. package/dist/transport-BJweqDPj.js +715 -0
  161. package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
  162. package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
  163. package/dist/use-tween-5HZ55_9d.js +72 -0
  164. package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
  165. package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
  166. package/package.json +26 -5
  167. package/recipes/counting-cards.tsx +656 -0
  168. package/recipes/explorable-essay.tsx +172 -0
  169. package/skills/extend-elements/SKILL.md +21 -0
  170. package/skills/plan-lesson/SKILL.md +86 -0
  171. package/skills/plan-lesson/references/plan-format.md +114 -0
  172. package/skills/plan-lesson/references/worked-plan.md +171 -0
  173. package/skills/review-elements/SKILL.md +4 -2
  174. package/skills/review-explainer/SKILL.md +97 -0
  175. package/skills/upgrade-elements/references/releases.md +65 -0
  176. package/skills/use-elements/SKILL.md +18 -16
  177. package/skills/use-elements/references/kits.md +2 -20
  178. package/skills/use-elements/references/teaching.md +36 -0
  179. package/skills/write-explainer/SKILL.md +112 -0
  180. package/skills/write-explainer/references/article.md +164 -0
  181. package/skills/write-explainer/references/lesson.md +148 -0
  182. package/skills/write-explainer/references/mdx.md +78 -0
  183. package/skills/write-explainer/references/scene-parts.md +273 -0
  184. package/skills/write-explainer/references/scene.md +168 -0
  185. package/skills/write-explainer/references/tutor.md +104 -0
  186. package/skills/write-explainer/references/worked-essay.md +459 -0
  187. package/templates/essay/AGENTS.md +14 -0
  188. package/templates/essay/README.md +59 -0
  189. package/templates/essay/index.html +17 -0
  190. package/templates/essay/package.template.json +21 -0
  191. package/templates/essay/plan.json +96 -0
  192. package/templates/essay/src/essay.mdx +97 -0
  193. package/templates/essay/src/figures.tsx +92 -0
  194. package/templates/essay/src/lesson.ts +83 -0
  195. package/templates/essay/src/main.tsx +53 -0
  196. package/templates/essay/src/mdx.d.ts +7 -0
  197. package/templates/essay/tsconfig.template.json +15 -0
  198. package/templates/essay/vite.config.template.txt +8 -0
  199. package/dist/kits/explainers.js +0 -452
  200. package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
  201. package/dist/packages/kits/src/explainers/index.d.ts +0 -8
  202. package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
  203. /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
  204. /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ValueFormat } from '../../../../charts/src/index.ts';
3
+ import type { PlotGrid } from '../../../../charts/src/plot/index.ts';
4
+ /** One axis of the plane: its title, how its numbers are written, and where its ticks fall. */
5
+ export type SceneAxis = {
6
+ /** The axis title, with its unit: "Weight (kg)". Left out, the axis has no title. */
7
+ readonly label?: string | undefined;
8
+ /** How tick labels write a number. Defaults to at most two decimals. */
9
+ readonly format?: ValueFormat | undefined;
10
+ /** The values that get a tick. Left out, round values are chosen from the part of the box the camera shows. */
11
+ readonly ticks?: ReadonlyArray<number> | undefined;
12
+ };
13
+ export type SceneAxesProps = {
14
+ /** Defaults to `axes`. */
15
+ readonly id?: string | undefined;
16
+ /** The horizontal axis, along the bottom of the box. */
17
+ readonly x?: SceneAxis | undefined;
18
+ /** The vertical axis, along the left of the box. */
19
+ readonly y?: SceneAxis | undefined;
20
+ /** Which ticks draw a line across the plot. Defaults to `y`, horizontal lines, as in a chart. */
21
+ readonly grid?: PlotGrid | undefined;
22
+ /** False fades the axes out and gives their room back to the box. */
23
+ readonly isShown?: boolean | undefined;
24
+ };
25
+ /**
26
+ * The x and y axes of the scene's data box: ticks, titles and grid lines drawn with the parts a chart uses. The scene
27
+ * keeps room for the tick labels and titles beside the box, and the ticks follow the camera. Put it first in the
28
+ * scene.
29
+ */
30
+ export declare function SceneAxes({ id, x, y, grid, isShown }: SceneAxesProps): ReactNode;
@@ -0,0 +1,42 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../../charts/src/index.ts';
3
+ import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
4
+ import type { Pace } from '../../time/tween.ts';
5
+ import type { ScenePosition } from '../scene-geometry.ts';
6
+ import type { ScenePlaneLabels } from './plane-labels.ts';
7
+ import type { SceneCurveResolution, ScenePlaneThickness } from './plane-math.ts';
8
+ export type SceneCurveProps = {
9
+ /** Stable across states: the curve with this id eases from its old shape to the new one. */
10
+ readonly id: string;
11
+ /** The curve as data: `[x, y]` pairs with strictly increasing x. Give this or `of`. */
12
+ readonly points?: ReadonlyArray<ScenePosition> | undefined;
13
+ /** The curve as a function of x, sampled across the scene's x range. Give this or `points`. */
14
+ readonly of?: ((across: number) => number) | undefined;
15
+ /** How many samples `of` takes. Defaults to `regular`. Samples are also how a curve eases between shapes. */
16
+ readonly resolution?: SceneCurveResolution | undefined;
17
+ /** The readout sentence. With one, the arrow keys reach the curve. */
18
+ readonly label?: string | undefined;
19
+ /** The hue that names the curve. Left out, the tone scope's tone for the id, or the first series hue. */
20
+ readonly tone?: ChartTone | undefined;
21
+ /** `context` draws the curve gray; the others yield to inspection. */
22
+ readonly emphasis?: MarkEmphasis | undefined;
23
+ /** Dashed for a curve that is modelled: a fit, a projection or a baseline. */
24
+ readonly isDashed?: boolean | undefined;
25
+ /** The stroke width by name. Defaults to `regular`. */
26
+ readonly thickness?: ScenePlaneThickness | undefined;
27
+ /** Fills the area between the curve and this y value with a pale wash of its tone. */
28
+ readonly fillTo?: number | undefined;
29
+ /** False fades the curve out and takes it out of the keyboard order. */
30
+ readonly isShown?: boolean | undefined;
31
+ /** True keeps the curve at full strength while the rest recede. */
32
+ readonly isActive?: boolean | undefined;
33
+ /** Overrides the scene's pace for this curve. */
34
+ readonly pace?: Pace | undefined;
35
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
36
+ };
37
+ /**
38
+ * A curve in the scene's data box, from points or from a function of x: a function a lesson explains, a loss, a fit.
39
+ * Give it new points or a new function and it eases from the old shape to the new one. Wires and callouts that name it
40
+ * attach at its middle.
41
+ */
42
+ export declare function SceneCurve({ id, points, of, resolution, label, tone, emphasis, isDashed, thickness, fillTo, isShown, isActive, pace, labels: labelInput, }: SceneCurveProps): ReactNode;
@@ -0,0 +1,59 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../../charts/src/index.ts';
3
+ import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
4
+ import type { Pace } from '../../time/tween.ts';
5
+ import type { ScenePosition } from '../scene-geometry.ts';
6
+ import type { ScenePlaneLabels } from './plane-labels.ts';
7
+ /** Why a point moved: a pointer drag, or an arrow key. A cancelled drag reports `drag` with the starting position. */
8
+ export type ScenePointMoveDetails = {
9
+ readonly reason: 'drag' | 'step-key';
10
+ readonly event: PointerEvent | KeyboardEvent;
11
+ };
12
+ /** What a movable point keeps fixed: `x` moves it along x only, `y` along y only, a function along that curve. */
13
+ export type ScenePointAlong = 'x' | 'y' | ((across: number) => number);
14
+ /** The number params of the nearest `Lesson` a moved point writes: its x position to one, its y position to another. */
15
+ export type ScenePointSets = {
16
+ readonly x?: string | undefined;
17
+ readonly y?: string | undefined;
18
+ };
19
+ export type ScenePointProps = {
20
+ /** Stable across states: the point with this id eases to its new position. */
21
+ readonly id: string;
22
+ /** The point's position, in the scene's data units. Wires, callouts and projections attach to it. */
23
+ readonly at: ScenePosition;
24
+ /** The readout sentence. With one, the arrow keys reach the point. Required when the point can move. */
25
+ readonly label?: string | undefined;
26
+ /** Short text beside the point, placed where it touches no curve. */
27
+ readonly text?: string | undefined;
28
+ /** The hue that names the point. Left out, the tone scope's tone for the id, or the first series hue. */
29
+ readonly tone?: ChartTone | undefined;
30
+ /** `context` draws the point gray; the others yield to inspection. */
31
+ readonly emphasis?: MarkEmphasis | undefined;
32
+ /** False fades the point out and takes it out of the keyboard order. */
33
+ readonly isShown?: boolean | undefined;
34
+ /** True keeps the point and what attaches to it at full strength while the rest recede. */
35
+ readonly isActive?: boolean | undefined;
36
+ /**
37
+ * Makes the point movable by a pointer and by the arrow keys when it is the keyboard cursor. It is told where the
38
+ * reader wants the point; the point stays where `at` says until the application moves it.
39
+ */
40
+ readonly onMove?: ((position: ScenePosition, details: ScenePointMoveDetails) => void) | undefined;
41
+ /**
42
+ * Makes the point movable and names the lesson number params its position writes, as `{ x: 'weight' }`. A move sets
43
+ * them in one change, on each param's step grid and inside its range; `at` stays the author's, read from the lesson.
44
+ */
45
+ readonly sets?: ScenePointSets | undefined;
46
+ /** The step, in data units, that a moved point lands on along each axis it moves. A bound axis takes its param's. */
47
+ readonly snap?: number | undefined;
48
+ /** Limits the movement. Left out, a point bound on one axis moves along it, and any other moves freely in the box. */
49
+ readonly along?: ScenePointAlong | undefined;
50
+ /** Overrides the scene's pace for this point. A drag always follows the pointer at once. */
51
+ readonly pace?: Pace | undefined;
52
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
53
+ };
54
+ /**
55
+ * A point at a position in the scene, with optional text beside it. Give it `sets` or `onMove` and the reader grabs it
56
+ * with a pointer, or moves it with the arrow keys while it is the keyboard cursor. It follows the pointer at once and
57
+ * eases only when the application moves it.
58
+ */
59
+ export declare function ScenePoint({ id, at, label, text, tone, emphasis, isShown, isActive, onMove, sets, snap, along, pace, labels: labelInput, }: ScenePointProps): ReactNode;
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone, ValueFormat } from '../../../../charts/src/index.ts';
3
+ import type { Pace } from '../../time/tween.ts';
4
+ import type { ScenePosition } from '../scene-geometry.ts';
5
+ import type { ScenePlaneLabels } from './plane-labels.ts';
6
+ export type SceneProjectionProps = {
7
+ /** Stable across states. */
8
+ readonly id: string;
9
+ /** The id of a `ScenePoint`, or any placed object, to follow. The lines stay under it. Give this or `at`. */
10
+ readonly of?: string | undefined;
11
+ /** A fixed position to project, in the scene's data units. Give this or `of`. */
12
+ readonly at?: ScenePosition | undefined;
13
+ /** How the values written on the axes are formatted. Defaults to at most two decimals. */
14
+ readonly format?: ValueFormat | undefined;
15
+ /** The hue of the dashed lines. Left out, the tone scope's tone for the id, or neutral. */
16
+ readonly tone?: ChartTone | undefined;
17
+ /** False fades the projection out. */
18
+ readonly isShown?: boolean | undefined;
19
+ /** Overrides the scene's pace for this projection. */
20
+ readonly pace?: Pace | undefined;
21
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
22
+ };
23
+ /**
24
+ * Dashed lines from a point down to the x axis and across to the y axis, with its two values written where they meet
25
+ * the axes. Use it to show what a point's position means: the input that went in and the value that came out.
26
+ */
27
+ export declare function SceneProjection({ id, of, at, format, tone, isShown, pace, labels: labelInput, }: SceneProjectionProps): ReactNode;
@@ -0,0 +1,38 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../../charts/src/index.ts';
3
+ import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
4
+ import type { Pace } from '../../time/tween.ts';
5
+ import type { ScenePosition } from '../scene-geometry.ts';
6
+ import type { ScenePlaneLabels } from './plane-labels.ts';
7
+ export type SceneRegionProps = {
8
+ /** Stable across states: the region with this id eases its corners to their new places. */
9
+ readonly id: string;
10
+ /** The band between two x values, over the box's whole height. Give one of this, `above`, `below` or `points`. */
11
+ readonly between?: readonly [number, number] | undefined;
12
+ /** Everything above this y value. */
13
+ readonly above?: number | undefined;
14
+ /** Everything below this y value. */
15
+ readonly below?: number | undefined;
16
+ /** A polygon, as corners in order. */
17
+ readonly points?: ReadonlyArray<ScenePosition> | undefined;
18
+ /** The readout sentence. With one, the arrow keys reach the region. */
19
+ readonly label?: string | undefined;
20
+ /** Short text inside the region, placed where it touches no curve. */
21
+ readonly text?: string | undefined;
22
+ /** The hue of the wash. Left out, the tone scope's tone for the id, or neutral. */
23
+ readonly tone?: ChartTone | undefined;
24
+ /** `context` draws the region gray; the others yield to inspection. */
25
+ readonly emphasis?: MarkEmphasis | undefined;
26
+ /** False fades the region out and takes it out of the keyboard order. */
27
+ readonly isShown?: boolean | undefined;
28
+ /** True keeps the region at full strength while the rest recede. */
29
+ readonly isActive?: boolean | undefined;
30
+ /** Overrides the scene's pace for this region. */
31
+ readonly pace?: Pace | undefined;
32
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
33
+ };
34
+ /**
35
+ * A filled region of the plane: a band between two x values, everything above or below a value, or a polygon. It is a
36
+ * pale wash in its tone, behind the curves. Use it for a zone a lesson names, such as overfitting or a safe range.
37
+ */
38
+ export declare function SceneRegion({ id, between, above, below, points, label, text, tone, emphasis, isShown, isActive, pace, labels: labelInput, }: SceneRegionProps): ReactNode;
@@ -0,0 +1,35 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../../charts/src/index.ts';
3
+ import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
4
+ import type { Pace } from '../../time/tween.ts';
5
+ import type { ScenePlaneLabels } from './plane-labels.ts';
6
+ export type SceneRuleProps = {
7
+ /** Stable across states: the rule with this id eases to its new value. */
8
+ readonly id: string;
9
+ /** Draws a vertical line at this x value. Give this or `y`. */
10
+ readonly x?: number | undefined;
11
+ /** Draws a horizontal line at this y value. Give this or `x`. */
12
+ readonly y?: number | undefined;
13
+ /** The readout sentence. With one, the arrow keys reach the rule. */
14
+ readonly label?: string | undefined;
15
+ /** Short text at the rule's end, such as "threshold" or "limit", placed where it touches no curve. */
16
+ readonly text?: string | undefined;
17
+ /** The hue of the line. Left out, the tone scope's tone for the id, or the reference gray. */
18
+ readonly tone?: ChartTone | undefined;
19
+ /** `context` draws the rule gray; the others yield to inspection. */
20
+ readonly emphasis?: MarkEmphasis | undefined;
21
+ /** A rule is a reference, so it is dashed. Pass false for a solid one. */
22
+ readonly isDashed?: boolean | undefined;
23
+ /** False fades the rule out and takes it out of the keyboard order. */
24
+ readonly isShown?: boolean | undefined;
25
+ /** True keeps the rule at full strength while the rest recede. */
26
+ readonly isActive?: boolean | undefined;
27
+ /** Overrides the scene's pace for this rule. */
28
+ readonly pace?: Pace | undefined;
29
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
30
+ };
31
+ /**
32
+ * A horizontal or vertical reference line at a value, with a short label at its end: a threshold, a limit, an
33
+ * asymptote. It is dashed because it is a reference, not an observation. Move its value and it eases there.
34
+ */
35
+ export declare function SceneRule({ id, x, y, label, text, tone, emphasis, isDashed, isShown, isActive, pace, labels: labelInput, }: SceneRuleProps): ReactNode;
@@ -0,0 +1,39 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../../charts/src/index.ts';
3
+ import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
4
+ import type { Pace } from '../../time/tween.ts';
5
+ import type { ScenePosition } from '../scene-geometry.ts';
6
+ import type { ScenePlaneLabels } from './plane-labels.ts';
7
+ import type { ScenePlaneThickness } from './plane-math.ts';
8
+ export type SceneVectorProps = {
9
+ /** Stable across states: the vector with this id eases its ends to their new places. */
10
+ readonly id: string;
11
+ /** Where the arrow points, in the scene's data units. */
12
+ readonly to: ScenePosition;
13
+ /** Where the arrow starts. Defaults to the origin. */
14
+ readonly from?: ScenePosition | undefined;
15
+ /** The readout sentence. With one, the arrow keys reach the vector. */
16
+ readonly label?: string | undefined;
17
+ /** Short text beside the arrow's head, placed where it touches no curve. */
18
+ readonly text?: string | undefined;
19
+ /** The hue of the arrow. Left out, the tone scope's tone for the id, or the second series hue. */
20
+ readonly tone?: ChartTone | undefined;
21
+ /** `context` draws the vector gray; the others yield to inspection. */
22
+ readonly emphasis?: MarkEmphasis | undefined;
23
+ /** Dashed for a vector that is modelled or proposed, such as a step not yet taken. */
24
+ readonly isDashed?: boolean | undefined;
25
+ /** The stroke width by name. Defaults to `regular`. */
26
+ readonly thickness?: ScenePlaneThickness | undefined;
27
+ /** False fades the vector out and takes it out of the keyboard order. */
28
+ readonly isShown?: boolean | undefined;
29
+ /** True keeps the vector at full strength while the rest recede. */
30
+ readonly isActive?: boolean | undefined;
31
+ /** Overrides the scene's pace for this vector. */
32
+ readonly pace?: Pace | undefined;
33
+ readonly labels?: Partial<ScenePlaneLabels> | undefined;
34
+ };
35
+ /**
36
+ * An arrow in the scene from one position to another: a gradient, a step, a velocity. Move either end and the arrow
37
+ * eases there. Give it `text` to name its head, and a `label` to make it an item the reader can inspect.
38
+ */
39
+ export declare function SceneVector({ id, to, from, label, text, tone, emphasis, isDashed, thickness, isShown, isActive, pace, labels: labelInput, }: SceneVectorProps): ReactNode;
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from 'react';
2
+ /** The side of its members a bracket runs along. */
3
+ export type SceneBracketSide = 'top' | 'right' | 'bottom' | 'left';
4
+ export type SceneBracketProps = {
5
+ /** The ids the bracket spans. It follows them as they move. */
6
+ readonly of: ReadonlyArray<string>;
7
+ /** Defaults to `bracket:` and the first id. */
8
+ readonly id?: string | undefined;
9
+ /** The readout sentence and, unless `text` is set, the words drawn beside the bracket. */
10
+ readonly label?: string | undefined;
11
+ /** Shorter words to draw, when the label is a full sentence. */
12
+ readonly text?: string | undefined;
13
+ /** Defaults to `bottom`. A bracket with no room on its side moves to the opposite one. */
14
+ readonly side?: SceneBracketSide | undefined;
15
+ /** The room between the members and the bracket, in pixels. Defaults to 8. */
16
+ readonly padding?: number | undefined;
17
+ /** False fades the bracket out. */
18
+ readonly isShown?: boolean | undefined;
19
+ };
20
+ /**
21
+ * A bracket along one side of a set of scene objects, with words beside it: "the hidden layer", "three inputs". It
22
+ * follows its members as they move. Use a group for an outline around them instead.
23
+ */
24
+ export declare function SceneBracket({ of, id, label, text, side, padding, isShown, }: SceneBracketProps): ReactNode;
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * The side a callout prefers. `auto` prefers right, then left, below and above. A callout leaves its preferred side
4
+ * when that side would cover another object.
5
+ */
6
+ export type SceneCalloutSide = 'auto' | 'top' | 'right' | 'bottom' | 'left';
7
+ export type SceneCalloutProps = {
8
+ /** The id of the object the callout explains. */
9
+ readonly to: string;
10
+ /** Defaults to `callout:` and the target id. */
11
+ readonly id?: string | undefined;
12
+ /** The side the callout prefers. Defaults to `auto`. */
13
+ readonly side?: SceneCalloutSide | undefined;
14
+ /** The callout's widest width in pixels. Defaults to 176; the prose wraps inside it, and it narrows to find room. */
15
+ readonly width?: number | undefined;
16
+ /** False fades the callout and its leader out. Defaults to true. */
17
+ readonly isShown?: boolean | undefined;
18
+ /** The prose. */
19
+ readonly children: ReactNode;
20
+ };
21
+ /**
22
+ * Prose attached to a scene object by a leader line: "the weighted sum", "this weight just flipped sign". It sits
23
+ * beside its object and inside the frame, keeping off other objects, labels, wires and curves, narrowing when it must.
24
+ * It follows the object as it moves.
25
+ */
26
+ export declare function SceneCallout({ to, id, side, width, isShown, children, }: SceneCalloutProps): ReactNode;
@@ -0,0 +1,179 @@
1
+ import type { ChartTone, NumericDomain } from '../../../charts/src/index.ts';
2
+ import type { ContinuousScale, MarkEmphasis, PlotBox, ToneInput } from '../../../charts/src/plot/index.ts';
3
+ import type { Pace } from '../time/tween.ts';
4
+ import type { SceneFrame, SceneMargins, SceneRect, SceneShape, SceneView } from './scene-geometry.ts';
5
+ import type { SceneFrameKey, SceneFrameValues, SceneMember, SceneRegistry } from './scene-registry.ts';
6
+ import type { SceneDelay, SceneStaggerPlace } from './scene-stagger.ts';
7
+ import type { SceneLabels } from './scene-validate.ts';
8
+ /** The camera's animated view of the data box. */
9
+ export type SceneCamera = {
10
+ readonly get: () => SceneView;
11
+ readonly subscribe: (listener: () => void) => () => void;
12
+ };
13
+ /** The SVG groups under the HTML layer that SVG parts draw into, back to front. Null until the scene mounts. */
14
+ export type SceneLayerElements = {
15
+ readonly back: SVGGElement | null;
16
+ readonly wires: SVGGElement | null;
17
+ readonly front: SVGGElement | null;
18
+ };
19
+ /** What a scene shares with its parts that changes only with its props or its width, never per frame. */
20
+ export type SceneSetup = {
21
+ /** False for a part rendered outside any `Scene`. Such a part shows an inline error instead of drawing. */
22
+ readonly isInScene: boolean;
23
+ readonly registry: SceneRegistry;
24
+ readonly camera: SceneCamera;
25
+ /** The drawing area in the plot's CSS pixels. A node centered on the data box's edge stays whole inside the plot. */
26
+ readonly box: PlotBox;
27
+ /** The whole data box the scene declares. */
28
+ readonly domain: {
29
+ readonly x: NumericDomain;
30
+ readonly y: NumericDomain;
31
+ };
32
+ readonly pace: Pace;
33
+ readonly locale: string;
34
+ /** Resolves a record's tone: its own, then the enclosing tone scope's, then its place. */
35
+ readonly tone: (input: ToneInput) => ChartTone;
36
+ /** The weight magnitude that draws the thickest wire. */
37
+ readonly weightMax: number;
38
+ readonly layers: SceneLayerElements;
39
+ /** The scene's words, so parts write their errors in the author's language. */
40
+ readonly labels: SceneLabels;
41
+ /** The camera's scales for a view, computed once per frame and shared by every part. */
42
+ readonly scalesFor: (view: SceneView) => SceneScales;
43
+ };
44
+ /** The camera's scales for one view, with the pixel rectangle of an animated frame under them. */
45
+ export type SceneScales = {
46
+ readonly x: ContinuousScale;
47
+ readonly y: ContinuousScale;
48
+ readonly rectOf: (values: SceneFrameValues) => SceneRect;
49
+ };
50
+ /** The inspection state the scene's `Chart` holds, shared with every part. It changes only on inspection. */
51
+ export type SceneMarks = {
52
+ readonly inspected: string | null;
53
+ readonly selected: string | null;
54
+ readonly cursor: string | null;
55
+ /** The ids drawn at full strength while something is inspected or active, or null when nothing recedes. */
56
+ readonly lit: ReadonlySet<string> | null;
57
+ /** Whether the plot has keyboard focus, so the keyboard cursor is drawn. */
58
+ readonly isKeyboardFocused: boolean;
59
+ /** Moves focus to the plot, so the arrow keys carry on from a pressed object. */
60
+ readonly focusPlot: () => void;
61
+ };
62
+ /** The scene as a part sees it in this frame: the setup, plus the camera's current scales. */
63
+ export type SceneContextValue = SceneSetup & {
64
+ /** Maps data x to plot pixels through the camera. A position outside the view lands outside the box. */
65
+ readonly x: ContinuousScale;
66
+ /** Maps data y to plot pixels through the camera. y grows upward, as on a chart. */
67
+ readonly y: ContinuousScale;
68
+ readonly view: SceneView;
69
+ /** An object's pixel rectangle from its animated frame values. */
70
+ readonly rectOf: (values: SceneFrameValues) => SceneRect;
71
+ };
72
+ /** The scene's setup. `Scene` provides it; the default is a detached scene, so a part outside one never throws. */
73
+ export declare const SceneSetupContext: import("react").Context<SceneSetup>;
74
+ /** The scene's inspection state. `Scene` provides it from its `Chart`. */
75
+ export declare const SceneMarksContext: import("react").Context<SceneMarks>;
76
+ /** The pixel rectangle of an animated frame under two scales. */
77
+ export declare function frameRect({ values, x, y, }: {
78
+ readonly values: SceneFrameValues;
79
+ readonly x: ContinuousScale;
80
+ readonly y: ContinuousScale;
81
+ }): SceneRect;
82
+ /** `sceneScales` for one box, remembering the last view, so the parts drawn in a frame share one set of scales. */
83
+ export declare function cachedScales(setup: Pick<SceneSetup, 'box' | 'domain'>): (view: SceneView) => SceneScales;
84
+ /**
85
+ * The scene a part is drawn in, with the camera's scales for this frame. A part that calls it redraws while the camera
86
+ * moves. Outside a scene `isInScene` is false and the part should show an inline error.
87
+ */
88
+ export declare function useSceneContext(): SceneContextValue;
89
+ /** What a part tells the scene about one of its objects. Every field but `id`, `kind` and `values` is optional. */
90
+ export type SceneObjectInput<Key extends string> = {
91
+ /** Stable across renders. A change of any other field eases the object to the new state. */
92
+ readonly id: string;
93
+ /** The part's name for its objects, such as `node` or `card`. */
94
+ readonly kind: string;
95
+ /**
96
+ * The target center in data units, pixel shift and pixel size. Leave it out for objects placed by others, such as
97
+ * wires.
98
+ */
99
+ readonly frame?: SceneFrame | undefined;
100
+ /**
101
+ * True when the frame only draws, so the scene makes no room for it: a point on a curve, or a card its stack makes
102
+ * room for. Left false, the margins keep the frame whole and the derived minimum width keeps it off its neighbours.
103
+ */
104
+ readonly isFloating?: boolean | undefined;
105
+ /** The room the object needs outside the data box, per side in pixels, such as an axis's tick labels. */
106
+ readonly margins?: SceneMargins | undefined;
107
+ /** The stacking order, 0 by default. Higher draws above and comes later among keyboard items that share a place. */
108
+ readonly order?: number | undefined;
109
+ /** How long every change waits before it starts. Defaults to 0. */
110
+ readonly delay?: SceneDelay | undefined;
111
+ /** The object's place in a stagger group: changes in one update start one step apart, a lone change at once. */
112
+ readonly stagger?: SceneStaggerPlace | undefined;
113
+ /** More numbers to ease with the frame, such as a card's `turn`. Pass `{}` when there are none. */
114
+ readonly values: Readonly<Record<Key, number>>;
115
+ /** The outline wires attach to. Defaults to `box`. */
116
+ readonly shape?: SceneShape | undefined;
117
+ /** The readout sentence. With one, the object is an item the arrow keys step through. */
118
+ readonly label?: string | undefined;
119
+ /** The ids the object attaches to. The scene reports one that does not exist. */
120
+ readonly attaches?: ReadonlyArray<string> | undefined;
121
+ /** The pixels an object that joins two others keeps between them, such as a wire's room for its arrow and text. */
122
+ readonly room?: number | undefined;
123
+ /**
124
+ * What the object draws around the objects it attaches to, in pixels per side, such as a group's outline and name.
125
+ * The scene keeps it inside the margins.
126
+ */
127
+ readonly surround?: SceneMargins | undefined;
128
+ /** False fades the object out and takes it out of the keyboard order. Defaults to true. */
129
+ readonly isShown?: boolean | undefined;
130
+ /** True keeps the object at full strength while others recede, like an inspected one. */
131
+ readonly isActive?: boolean | undefined;
132
+ /** The emphasis the author chose. `context` always draws gray; the others yield to inspection. */
133
+ readonly emphasis?: MarkEmphasis | undefined;
134
+ /** Why this object's own input cannot be drawn, naming its id. The scene shows it as invalid. */
135
+ readonly problem?: string | undefined;
136
+ /** Overrides the scene's pace for this object. */
137
+ readonly pace?: Pace | undefined;
138
+ };
139
+ /** One object as a part draws it in this frame. */
140
+ export type SceneObjectState<Key extends string> = {
141
+ /** The eased values on screen now: the frame keys, `opacity`, and the part's own `values`. */
142
+ readonly values: Readonly<Record<Key | SceneFrameKey, number>>;
143
+ /** The pixel rectangle now, or undefined for an object without a frame. */
144
+ readonly rect: SceneRect | undefined;
145
+ /** False once a hidden object has faded out completely. Draw nothing, or keep it invisible to save its state. */
146
+ readonly isVisible: boolean;
147
+ readonly isInspected: boolean;
148
+ readonly isSelected: boolean;
149
+ /** Whether the keyboard cursor rests here while the plot has keyboard focus. */
150
+ readonly isCursor: boolean;
151
+ /** The emphasis to draw with, from the author's choice, inspection and active objects. */
152
+ readonly emphasis: MarkEmphasis;
153
+ /**
154
+ * How strongly to draw now: 1 at full strength, less while the object recedes. It eases on the shared clock; multiply
155
+ * it into the opacity of a part drawn in HTML.
156
+ */
157
+ readonly strength: number;
158
+ /** Moves focus to the scene's plot, so the arrow keys carry on from a pressed object. */
159
+ readonly focusPlot: () => void;
160
+ readonly scene: SceneContextValue;
161
+ };
162
+ /**
163
+ * Registers an object with the nearest scene and returns its animated state. The first render shows the target with no
164
+ * motion; a later change eases there on the shared clock, and an object first rendered after the scene's first paint
165
+ * fades in. Only the calling part redraws while its object moves.
166
+ */
167
+ export declare function useSceneObject<Key extends string>(input: SceneObjectInput<Key>): SceneObjectState<Key>;
168
+ /** Another object as a follower sees it in this frame, such as a node a wire attaches to. */
169
+ export type SceneFollowed = {
170
+ readonly member: SceneMember;
171
+ readonly values: SceneFrameValues;
172
+ /** The pixel rectangle now, or undefined for an object without a frame. */
173
+ readonly rect: SceneRect | undefined;
174
+ };
175
+ /**
176
+ * Follows other objects by id: their members and animated geometry, redrawn on each frame any of them moves. Use it in
177
+ * a part that attaches to others, as wires, groups and callouts do. An id with no object yields undefined.
178
+ */
179
+ export declare function useSceneFrames(ids: ReadonlyArray<string>): ReadonlyArray<SceneFollowed | undefined>;
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ChartTone } from '../../../charts/src/index.ts';
3
+ import type { ContinuousScale, PlotBox, ToneInput } from '../../../charts/src/plot/index.ts';
4
+ import type { SceneView } from './scene-geometry.ts';
5
+ import type { SceneLayerName } from './scene-layer.tsx';
6
+ /** What a custom drawing receives, in this frame. */
7
+ export type SceneDrawing = {
8
+ /** Data x to plot pixels, through the camera. */
9
+ readonly x: ContinuousScale;
10
+ /** Data y to plot pixels, through the camera. y grows upward. */
11
+ readonly y: ContinuousScale;
12
+ /** The drawing area in plot pixels. */
13
+ readonly box: PlotBox;
14
+ /** The part of the data box the camera shows. */
15
+ readonly view: SceneView;
16
+ /** Resolves a record's tone through the tone scope, as the scene's own parts do. */
17
+ readonly tone: (input: ToneInput) => ChartTone;
18
+ /** The color of a tone, for a `fill` or `stroke`. */
19
+ readonly color: (tone: ChartTone) => string;
20
+ };
21
+ export type SceneCustomProps = {
22
+ /** Under the wires, or above them. Both lie under the nodes. Defaults to `front`. */
23
+ readonly layer?: Exclude<SceneLayerName, 'wires'> | undefined;
24
+ /** Returns SVG in plot pixels. It is called again on every camera frame. */
25
+ readonly children: (drawing: SceneDrawing) => ReactNode;
26
+ };
27
+ /**
28
+ * SVG the scene lacks, drawn with the scene's scales, box and tones so it moves with the camera: an axis, a decision
29
+ * boundary, a shaded region. Use the kernel marks inside it so channels keep their meaning.
30
+ */
31
+ export declare function SceneCustom({ layer, children }: SceneCustomProps): ReactNode;