@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.
- package/README.md +288 -5
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/article-BXZr10QQ.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +1389 -75
- package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
- package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
- package/dist/charts/cartesian.js +1 -1
- package/dist/charts/cells.js +1 -1
- package/dist/charts/comparison.js +1 -1
- package/dist/charts/distribution.js +1 -1
- package/dist/charts/figure.js +12 -12
- package/dist/charts/graph.js +1 -1
- package/dist/charts/hierarchy.js +1 -1
- package/dist/charts/image.js +1 -1
- package/dist/charts/matrix.js +3 -2
- package/dist/charts/plot.js +4 -4
- package/dist/charts/relationship.js +1 -1
- package/dist/charts/text.js +1 -1
- package/dist/charts/timeline.js +1 -1
- package/dist/charts/trend.js +1 -1
- package/dist/charts.js +2 -2
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/collections.js +1 -1
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
- package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
- package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
- package/dist/forms.js +1 -1
- package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
- package/dist/kits/evaluation.js +5 -5
- package/dist/kits/interpretability.js +9 -9
- package/dist/kits/operations.js +4 -4
- package/dist/kits/training.js +4 -4
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/mdx.js +227 -0
- package/dist/packages/charts/src/matrix/index.d.ts +1 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
- package/dist/packages/teaching/src/agent/index.d.ts +11 -0
- package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
- package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
- package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
- package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
- package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
- package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
- package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
- package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
- package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
- package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
- package/dist/packages/teaching/src/article/article.d.ts +42 -0
- package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
- package/dist/packages/teaching/src/article/beat.d.ts +16 -0
- package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
- package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
- package/dist/packages/teaching/src/article/figure.d.ts +51 -0
- package/dist/packages/teaching/src/article/index.d.ts +31 -0
- package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
- package/dist/packages/teaching/src/article/notes.d.ts +36 -0
- package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
- package/dist/packages/teaching/src/article/predict.d.ts +58 -0
- package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
- package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
- package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
- package/dist/packages/teaching/src/article/tex.d.ts +12 -0
- package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
- package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
- package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
- package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
- package/dist/packages/teaching/src/article/walk.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
- package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
- package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
- package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
- package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
- package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
- package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
- package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
- package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
- package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
- package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
- package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
- package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
- package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
- package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
- package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
- package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
- package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
- package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
- package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
- package/dist/packages/teaching/src/scene/index.d.ts +77 -0
- package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
- package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
- package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
- package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
- package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
- package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
- package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
- package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
- package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
- package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
- package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
- package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
- package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
- package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
- package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
- package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
- package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
- package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
- package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
- package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
- package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
- package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
- package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
- package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
- package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
- package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
- package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
- package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
- package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
- package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
- package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
- package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
- package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
- package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
- package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
- package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
- package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
- package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
- package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
- package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
- package/dist/packages/teaching/src/spec/index.d.ts +14 -0
- package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
- package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
- package/dist/packages/teaching/src/time/clock.d.ts +7 -0
- package/dist/packages/teaching/src/time/tween.d.ts +19 -0
- package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
- package/dist/param-CqKUTHaO.js +450 -0
- package/dist/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
- package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
- package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
- package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
- package/dist/scene-0z2gbaDE.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
- package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
- package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
- package/dist/styles2.css +475 -18
- package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
- package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
- package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
- package/dist/transport-BJweqDPj.js +715 -0
- package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
- package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
- package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
- package/package.json +26 -5
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +21 -0
- package/skills/plan-lesson/SKILL.md +86 -0
- package/skills/plan-lesson/references/plan-format.md +114 -0
- package/skills/plan-lesson/references/worked-plan.md +171 -0
- package/skills/review-elements/SKILL.md +4 -2
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/references/releases.md +65 -0
- package/skills/use-elements/SKILL.md +18 -16
- package/skills/use-elements/references/kits.md +2 -20
- package/skills/use-elements/references/teaching.md +36 -0
- package/skills/write-explainer/SKILL.md +112 -0
- package/skills/write-explainer/references/article.md +164 -0
- package/skills/write-explainer/references/lesson.md +148 -0
- package/skills/write-explainer/references/mdx.md +78 -0
- package/skills/write-explainer/references/scene-parts.md +273 -0
- package/skills/write-explainer/references/scene.md +168 -0
- package/skills/write-explainer/references/tutor.md +104 -0
- package/skills/write-explainer/references/worked-essay.md +459 -0
- package/templates/essay/AGENTS.md +14 -0
- package/templates/essay/README.md +59 -0
- package/templates/essay/index.html +17 -0
- package/templates/essay/package.template.json +21 -0
- package/templates/essay/plan.json +96 -0
- package/templates/essay/src/essay.mdx +97 -0
- package/templates/essay/src/figures.tsx +92 -0
- package/templates/essay/src/lesson.ts +83 -0
- package/templates/essay/src/main.tsx +53 -0
- package/templates/essay/src/mdx.d.ts +7 -0
- package/templates/essay/tsconfig.template.json +15 -0
- package/templates/essay/vite.config.template.txt +8 -0
- package/dist/kits/explainers.js +0 -452
- package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
- package/dist/packages/kits/src/explainers/index.d.ts +0 -8
- package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
- /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
- /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** The accessible names of the transport's buttons. `{label}` in a name is replaced by the param's label. */
|
|
3
|
+
export type TransportLabels = {
|
|
4
|
+
readonly play: string;
|
|
5
|
+
readonly pause: string;
|
|
6
|
+
readonly stepBack: string;
|
|
7
|
+
readonly stepForward: string;
|
|
8
|
+
readonly scrub: string;
|
|
9
|
+
};
|
|
10
|
+
export type TransportProps = {
|
|
11
|
+
/** The number param whose `Playback` this transport plays. */
|
|
12
|
+
readonly for: string;
|
|
13
|
+
readonly labels?: Partial<TransportLabels> | undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Play or pause, step back, step forward, a scrub slider and the value, in one row that wraps on a narrow screen. It
|
|
17
|
+
* plays the `Playback` of the same param, and every button and the slider work from the keyboard.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Transport({ for: name, labels }: TransportProps): ReactNode;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LessonDefinition, LessonParams, LessonValues, ParamValues } from './define-lesson.ts';
|
|
2
|
+
import type { LessonChangeOrigin, LessonPlaceChangeReason } from './lesson-store.ts';
|
|
3
|
+
/** What `useLesson` returns: the lesson's values and the calls that change them, typed by its definition. */
|
|
4
|
+
export type LessonControls<Params extends LessonParams, Derived extends string, Beat extends string> = {
|
|
5
|
+
/** Every param and derived value, as they are now. */
|
|
6
|
+
readonly values: LessonValues<Params, Derived>;
|
|
7
|
+
/**
|
|
8
|
+
* Sets a param. A value outside its range or options throws an `Error` naming the param and its bounds. Every call
|
|
9
|
+
* here takes an optional origin: the reason, event and source its change reports.
|
|
10
|
+
*/
|
|
11
|
+
readonly set: <Name extends keyof Params & string>(name: Name, value: ParamValues<Params>[Name], origin?: LessonChangeOrigin) => boolean;
|
|
12
|
+
/** Sets several params in one change. */
|
|
13
|
+
readonly setMany: (values: Partial<ParamValues<Params>>, origin?: LessonChangeOrigin) => boolean;
|
|
14
|
+
/** Shows a state a beat declares, by its id, in one change. Params it does not name take their opening values. */
|
|
15
|
+
readonly show: (state: string, origin?: LessonChangeOrigin) => boolean;
|
|
16
|
+
/** Puts every param back to its opening value. */
|
|
17
|
+
readonly reset: () => boolean;
|
|
18
|
+
readonly beat: Beat | null;
|
|
19
|
+
/** The reveal step inside the beat, from 0. */
|
|
20
|
+
readonly step: number;
|
|
21
|
+
/** Moves to a beat, at reveal step `step` or its first. */
|
|
22
|
+
readonly goTo: (beat: Beat, step?: number, origin?: LessonChangeOrigin<LessonPlaceChangeReason>) => boolean;
|
|
23
|
+
/** Shows the next reveal step, or the next beat. */
|
|
24
|
+
readonly next: (origin?: LessonChangeOrigin<LessonPlaceChangeReason>) => boolean;
|
|
25
|
+
/** Hides the last reveal step, or goes back a beat. */
|
|
26
|
+
readonly previous: (origin?: LessonChangeOrigin<LessonPlaceChangeReason>) => boolean;
|
|
27
|
+
readonly locale: string;
|
|
28
|
+
readonly lesson: LessonDefinition<Params, Derived, Beat>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The values of `lesson` and the calls that change them, from the nearest `Lesson` that renders it. Types come from the
|
|
32
|
+
* definition, so `values.bet` is a number and `set('bet', 'high')` does not compile. Throws outside that lesson.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useLesson<Params extends LessonParams, Derived extends string, Beat extends string>(lesson: LessonDefinition<Params, Derived, Beat>): LessonControls<Params, Derived, Beat>;
|
|
35
|
+
/** The nearest lesson's values and calls, untyped, for parts that work in any lesson. Throws outside a lesson. */
|
|
36
|
+
export declare function useLessonContext(): LessonControls<LessonParams, string, string>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import { Aside, Beat, Challenge, Cite, DiagramPart, Figure, FigureReference, Footnote, Predict, References, Reveal, Scrolly, ScrollyStep, Term, TeX } from '../article/index.ts';
|
|
3
|
+
import { Param, ParamChoice, ParamSlider, ParamToggle, Playback, Transport, Value } from '../lesson/index.ts';
|
|
4
|
+
import { LessonFlow, MorphScope, Scene, SceneAxes, SceneBracket, SceneCallout, SceneCard, SceneCells, SceneCurve, SceneCustom, SceneFlow, SceneGroup, SceneHighlight, SceneNode, ScenePoint, SceneProjection, SceneRegion, SceneRule, SceneSlot, SceneStack, SceneToken, SceneTokens, SceneVector, SceneWire } from '../scene/index.ts';
|
|
5
|
+
import { EssayCell, EssayCode, EssayEmphasis, EssayHeadCell, EssayImage, EssayItem, EssayLink, EssayList, EssayOrderedList, EssayParagraph, EssayPre, EssayQuote, EssayRule, EssaySection, EssayStrong, EssaySubsection, EssayTable } from './essay-markdown.tsx';
|
|
6
|
+
/** Any component an essay file may name: the map an MDX provider or a compiled MDX component's `components` takes. */
|
|
7
|
+
export type EssayComponents = Readonly<Record<string, ElementType>>;
|
|
8
|
+
/**
|
|
9
|
+
* The components an MDX essay uses without importing them. Markdown elements map to Elements typography that matches
|
|
10
|
+
* the article's prose, and every teaching part is available under its own name, such as `Beat`, `Param` or `Scene`.
|
|
11
|
+
* Math written with remark-math reaches `TeX` when the application adds `remark-math` to its MDX plugins.
|
|
12
|
+
*/
|
|
13
|
+
export declare const essayComponents: {
|
|
14
|
+
readonly h1: typeof EssaySection;
|
|
15
|
+
readonly h2: typeof EssaySection;
|
|
16
|
+
readonly h3: typeof EssaySubsection;
|
|
17
|
+
readonly h4: typeof EssaySubsection;
|
|
18
|
+
readonly p: typeof EssayParagraph;
|
|
19
|
+
readonly a: typeof EssayLink;
|
|
20
|
+
readonly ul: typeof EssayList;
|
|
21
|
+
readonly ol: typeof EssayOrderedList;
|
|
22
|
+
readonly li: typeof EssayItem;
|
|
23
|
+
readonly blockquote: typeof EssayQuote;
|
|
24
|
+
readonly code: typeof EssayCode;
|
|
25
|
+
readonly pre: typeof EssayPre;
|
|
26
|
+
readonly table: typeof EssayTable;
|
|
27
|
+
readonly th: typeof EssayHeadCell;
|
|
28
|
+
readonly td: typeof EssayCell;
|
|
29
|
+
readonly hr: typeof EssayRule;
|
|
30
|
+
readonly img: typeof EssayImage;
|
|
31
|
+
readonly em: typeof EssayEmphasis;
|
|
32
|
+
readonly strong: typeof EssayStrong;
|
|
33
|
+
readonly Beat: typeof Beat;
|
|
34
|
+
readonly Figure: typeof Figure;
|
|
35
|
+
readonly FigureReference: typeof FigureReference;
|
|
36
|
+
readonly Reveal: typeof Reveal;
|
|
37
|
+
readonly Aside: typeof Aside;
|
|
38
|
+
readonly Footnote: typeof Footnote;
|
|
39
|
+
readonly Cite: typeof Cite;
|
|
40
|
+
readonly TeX: typeof TeX;
|
|
41
|
+
readonly Term: typeof Term;
|
|
42
|
+
readonly DiagramPart: typeof DiagramPart;
|
|
43
|
+
readonly Scrolly: typeof Scrolly;
|
|
44
|
+
readonly ScrollyStep: typeof ScrollyStep;
|
|
45
|
+
readonly Predict: typeof Predict;
|
|
46
|
+
readonly Challenge: typeof Challenge;
|
|
47
|
+
readonly References: typeof References;
|
|
48
|
+
readonly Param: typeof Param;
|
|
49
|
+
readonly Value: typeof Value;
|
|
50
|
+
readonly ParamSlider: typeof ParamSlider;
|
|
51
|
+
readonly ParamChoice: typeof ParamChoice;
|
|
52
|
+
readonly ParamToggle: typeof ParamToggle;
|
|
53
|
+
readonly Playback: typeof Playback;
|
|
54
|
+
readonly Transport: typeof Transport;
|
|
55
|
+
readonly Scene: typeof Scene;
|
|
56
|
+
readonly SceneNode: typeof SceneNode;
|
|
57
|
+
readonly SceneWire: typeof SceneWire;
|
|
58
|
+
readonly SceneGroup: typeof SceneGroup;
|
|
59
|
+
readonly SceneBracket: typeof SceneBracket;
|
|
60
|
+
readonly SceneCallout: typeof SceneCallout;
|
|
61
|
+
readonly SceneHighlight: typeof SceneHighlight;
|
|
62
|
+
readonly SceneCustom: typeof SceneCustom;
|
|
63
|
+
readonly SceneAxes: typeof SceneAxes;
|
|
64
|
+
readonly SceneCurve: typeof SceneCurve;
|
|
65
|
+
readonly ScenePoint: typeof ScenePoint;
|
|
66
|
+
readonly SceneVector: typeof SceneVector;
|
|
67
|
+
readonly SceneRegion: typeof SceneRegion;
|
|
68
|
+
readonly SceneRule: typeof SceneRule;
|
|
69
|
+
readonly SceneProjection: typeof SceneProjection;
|
|
70
|
+
readonly SceneCard: typeof SceneCard;
|
|
71
|
+
readonly SceneStack: typeof SceneStack;
|
|
72
|
+
readonly SceneSlot: typeof SceneSlot;
|
|
73
|
+
readonly SceneCells: typeof SceneCells;
|
|
74
|
+
readonly SceneToken: typeof SceneToken;
|
|
75
|
+
readonly SceneTokens: typeof SceneTokens;
|
|
76
|
+
readonly SceneFlow: typeof SceneFlow;
|
|
77
|
+
readonly LessonFlow: typeof LessonFlow;
|
|
78
|
+
readonly MorphScope: typeof MorphScope;
|
|
79
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
/** A paragraph of the essay. */
|
|
3
|
+
export declare function EssayParagraph(props: ComponentProps<'p'>): ReactNode;
|
|
4
|
+
/** A Markdown `#` or `##` heading, drawn as the heading of a section inside a beat, whose own title is the `h2`. */
|
|
5
|
+
export declare function EssaySection({ children, ...props }: ComponentProps<'h3'>): ReactNode;
|
|
6
|
+
/** A Markdown `###` heading, drawn below a section heading. */
|
|
7
|
+
export declare function EssaySubsection({ children, ...props }: ComponentProps<'h4'>): ReactNode;
|
|
8
|
+
/** A bulleted list. */
|
|
9
|
+
export declare function EssayList(props: ComponentProps<'ul'>): ReactNode;
|
|
10
|
+
/** A numbered list. */
|
|
11
|
+
export declare function EssayOrderedList(props: ComponentProps<'ol'>): ReactNode;
|
|
12
|
+
/** One item of a list. */
|
|
13
|
+
export declare function EssayItem(props: ComponentProps<'li'>): ReactNode;
|
|
14
|
+
/** A quotation. */
|
|
15
|
+
export declare function EssayQuote(props: ComponentProps<'blockquote'>): ReactNode;
|
|
16
|
+
/** Emphasized text. */
|
|
17
|
+
export declare function EssayEmphasis(props: ComponentProps<'em'>): ReactNode;
|
|
18
|
+
/** Strong text. */
|
|
19
|
+
export declare function EssayStrong(props: ComponentProps<'strong'>): ReactNode;
|
|
20
|
+
/** A divider between two parts of a beat. */
|
|
21
|
+
export declare function EssayRule(props: ComponentProps<'hr'>): ReactNode;
|
|
22
|
+
/** An image that never outgrows the text column. */
|
|
23
|
+
export declare function EssayImage({ alt, ...props }: ComponentProps<'img'>): ReactNode;
|
|
24
|
+
/** A link. It follows the same rules as `ContentLink`: only web and mail addresses are followed. */
|
|
25
|
+
export declare function EssayLink({ href, title, children }: ComponentProps<'a'>): ReactNode;
|
|
26
|
+
/** A table that scrolls inside its own box when the column is narrower than it. */
|
|
27
|
+
export declare function EssayTable(props: ComponentProps<'table'>): ReactNode;
|
|
28
|
+
/** A table head cell. Its `align` attribute from a Markdown table column is kept. */
|
|
29
|
+
export declare function EssayHeadCell(props: ComponentProps<'th'>): ReactNode;
|
|
30
|
+
/** A table cell. Its `align` attribute is kept. */
|
|
31
|
+
export declare function EssayCell(props: ComponentProps<'td'>): ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Inline code, or inline math when remark-math marked it. Math reaches `TeX` with its TeX source, so the article's
|
|
34
|
+
* typesetter draws it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function EssayCode({ className, children, ...props }: ComponentProps<'code'>): ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* A fenced code block, drawn by `CodeBlock` with the language of the fence. Display math is a code element that
|
|
39
|
+
* remark-math marked, so it passes through to be typeset.
|
|
40
|
+
*/
|
|
41
|
+
export declare function EssayPre({ children }: ComponentProps<'pre'>): ReactNode;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ArticleProps, ArticleView } from '../article/index.ts';
|
|
3
|
+
import type { LessonParams } from '../lesson/index.ts';
|
|
4
|
+
import type { EssayComponents } from './essay-components.ts';
|
|
5
|
+
/** The metadata an essay file may export as `export const meta = { title: '…' }`, to spread onto `Essay`. */
|
|
6
|
+
export type EssayMeta = {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly authors?: ReadonlyArray<string> | undefined;
|
|
9
|
+
/** The publication date as an ISO date, such as `2026-11-23`. */
|
|
10
|
+
readonly date?: string | undefined;
|
|
11
|
+
readonly summary?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** The props a compiled MDX component takes: the components its elements and tags resolve to. */
|
|
14
|
+
export type EssayContentProps = {
|
|
15
|
+
readonly components?: EssayComponents;
|
|
16
|
+
};
|
|
17
|
+
/** A compiled MDX file: the default export of `essay.mdx` once the application's MDX plugin has compiled it. */
|
|
18
|
+
export type EssayContent = (props: EssayContentProps) => ReactNode;
|
|
19
|
+
export type EssayProps<Params extends LessonParams, Derived extends string, Beat extends string> = Omit<ArticleProps<Params, Derived, Beat>, 'children' | 'view'> & {
|
|
20
|
+
/** The compiled MDX file: `import Content from './essay.mdx'`. */
|
|
21
|
+
readonly content: EssayContent;
|
|
22
|
+
/** Components the essay file may use besides `essayComponents`, or instead of them under the same name. */
|
|
23
|
+
readonly components?: EssayComponents | undefined;
|
|
24
|
+
/** How the essay is arranged. Without it, the `view` address parameter decides: `?view=present|static|sheet`. */
|
|
25
|
+
readonly view?: ArticleView | undefined;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* An explorable essay written as one MDX file. It renders the compiled file inside an `Article` with `essayComponents`,
|
|
29
|
+
* so the file uses `Beat`, `Param`, `Figure`, `Scene` and the rest without imports. The file's elements are read once
|
|
30
|
+
* so the article sees its beats, and a compiled file that reads a context hook sits inside this component's render.
|
|
31
|
+
*/
|
|
32
|
+
export declare function Essay<Params extends LessonParams, Derived extends string, Beat extends string>({ content, components, view, ...article }: EssayProps<Params, Derived, Beat>): ReactNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explorable essays written in MDX. `Essay` renders a compiled MDX file as an `Article`. `essayComponents` lets the
|
|
3
|
+
* file use Markdown and every teaching part without imports. The application brings its own MDX compiler, such as
|
|
4
|
+
* `@mdx-js/rollup`.
|
|
5
|
+
*/
|
|
6
|
+
export type { EssayComponents } from './essay-components.ts';
|
|
7
|
+
export { essayComponents } from './essay-components.ts';
|
|
8
|
+
export type { EssayContent, EssayContentProps, EssayMeta, EssayProps } from './essay.tsx';
|
|
9
|
+
export { Essay } from './essay.tsx';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArticleView } from '../article/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The view the address asks for with `?view=present`, `static` or `sheet`, and `article` when it asks for none. The
|
|
4
|
+
* server and the first browser render show `article`, so the page hydrates cleanly before it switches.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useRequestedView(): ArticleView;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { NumericDomain } from '../../../../charts/src/index.ts';
|
|
2
|
+
import type { LessonGraph } from '../../lesson/define-lesson.ts';
|
|
3
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
4
|
+
/** Which way the layers of a flow advance: from left to right, or from top to bottom. */
|
|
5
|
+
export type FlowDirection = 'across' | 'down';
|
|
6
|
+
/** One value of a flow with its place: the layer it sits in and its row inside that layer. */
|
|
7
|
+
export type FlowSlot = {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly kind: 'param' | 'derived';
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly layer: number;
|
|
12
|
+
readonly row: number;
|
|
13
|
+
};
|
|
14
|
+
/** A lesson graph arranged in layers, ready to be placed in a box. */
|
|
15
|
+
export type FlowPlan = {
|
|
16
|
+
readonly slots: ReadonlyArray<FlowSlot>;
|
|
17
|
+
readonly edges: LessonGraph['edges'];
|
|
18
|
+
/** How many layers the values fill. */
|
|
19
|
+
readonly layers: number;
|
|
20
|
+
/** How many values the busiest layer holds. */
|
|
21
|
+
readonly rows: number;
|
|
22
|
+
};
|
|
23
|
+
/** The first name the graph does not hold, or undefined when it holds them all. */
|
|
24
|
+
export declare function unknownFlowName(graph: LessonGraph, names: ReadonlyArray<string>): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Arranges a lesson's derivation in layers. Each derived value sits one layer after the last value it reads, and each
|
|
27
|
+
* param one layer before the first value that reads it. Inside a layer, values follow the values they read.
|
|
28
|
+
*/
|
|
29
|
+
export declare function flowPlan(graph: LessonGraph, names?: ReadonlyArray<string>): FlowPlan;
|
|
30
|
+
/** The center of each value of a plan inside a data box: layers across or down the box, rows along the other axis. */
|
|
31
|
+
export declare function flowPositions({ plan, box, direction, }: {
|
|
32
|
+
readonly plan: FlowPlan;
|
|
33
|
+
readonly box: {
|
|
34
|
+
readonly x: NumericDomain;
|
|
35
|
+
readonly y: NumericDomain;
|
|
36
|
+
};
|
|
37
|
+
readonly direction: FlowDirection;
|
|
38
|
+
}): ReadonlyMap<string, ScenePosition>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { LessonValue } from '../../lesson/define-lesson.ts';
|
|
4
|
+
import type { Pace } from '../../time/tween.ts';
|
|
5
|
+
import type { FlowPlan } from './flow-layout.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Shows a lesson change as a cause: the values that changed glow once, layer after layer, and a dot runs along each
|
|
8
|
+
* wire between them. With reduced motion the touched values are marked at rest instead. It draws nothing until a value
|
|
9
|
+
* changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function FlowPulse({ plan, values, pace, tone, }: {
|
|
12
|
+
readonly plan: FlowPlan;
|
|
13
|
+
readonly values: Readonly<Record<string, LessonValue | undefined>>;
|
|
14
|
+
readonly pace: Pace;
|
|
15
|
+
readonly tone: ChartTone | undefined;
|
|
16
|
+
}): ReactNode;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone, NumericDomain, PlotHeight } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { AnyLesson } from '../../lesson/define-lesson.ts';
|
|
4
|
+
import type { SceneLabels } from '../scene-validate.ts';
|
|
5
|
+
import type { SceneProps } from '../scene.tsx';
|
|
6
|
+
import type { FlowDirection } from './flow-layout.ts';
|
|
7
|
+
/** The words a flow shows that are not the author's content. Placeholders in braces are filled in. */
|
|
8
|
+
export type SceneFlowLabels = {
|
|
9
|
+
readonly noLesson: string;
|
|
10
|
+
/** `{name}` is the name the author gave, `{lesson}` the lesson's id. */
|
|
11
|
+
readonly unknownName: string;
|
|
12
|
+
/** `{count}` is how many values share one column, `{limit}` how many the plot holds. */
|
|
13
|
+
readonly crowded: string;
|
|
14
|
+
/** The readout sentence of a value: `{label}` and its `{value}` in its format. */
|
|
15
|
+
readonly node: string;
|
|
16
|
+
/** Appended to a derived value's sentence when it has a formula: `{formula}`. */
|
|
17
|
+
readonly formula: string;
|
|
18
|
+
/** Appended to a value's sentence: `{names}` are the labels of the values it reads. */
|
|
19
|
+
readonly reads: string;
|
|
20
|
+
readonly on: string;
|
|
21
|
+
readonly off: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const sceneFlowLabels: {
|
|
24
|
+
readonly noLesson: 'SceneFlow needs a Lesson around it that renders its lesson.';
|
|
25
|
+
readonly unknownName: 'The flow names "{name}", which lesson "{lesson}" does not declare.';
|
|
26
|
+
readonly crowded: 'The flow stacks {count} values in one column, and this plot holds {limit}. Show fewer with `names`.';
|
|
27
|
+
readonly node: '{label}: {value}';
|
|
28
|
+
readonly formula: ', {formula}';
|
|
29
|
+
readonly reads: '. Reads {names}';
|
|
30
|
+
readonly on: 'on';
|
|
31
|
+
readonly off: 'off';
|
|
32
|
+
};
|
|
33
|
+
/** The pixel box of each value in a flow, big enough for a two-line label and an inline control. */
|
|
34
|
+
export declare const flowNodeSize: {
|
|
35
|
+
readonly width: 128;
|
|
36
|
+
readonly height: 64;
|
|
37
|
+
};
|
|
38
|
+
export type SceneFlowProps = {
|
|
39
|
+
/** The lesson to draw. Left out, the nearest `Lesson`'s. A `Lesson` that renders it must enclose the flow. */
|
|
40
|
+
readonly lesson?: AnyLesson | undefined;
|
|
41
|
+
/** Draw only these values and every value they read. Left out, the whole lesson. */
|
|
42
|
+
readonly names?: ReadonlyArray<string> | undefined;
|
|
43
|
+
/** Layers from left to right, or from top to bottom. Defaults to `across`. */
|
|
44
|
+
readonly layout?: FlowDirection | undefined;
|
|
45
|
+
/** The part of the scene's data box the flow fills. Left out, the whole box. */
|
|
46
|
+
readonly at?: {
|
|
47
|
+
readonly x: NumericDomain;
|
|
48
|
+
readonly y: NumericDomain;
|
|
49
|
+
} | undefined;
|
|
50
|
+
/** Plain text for a derived value's readout, by name, such as `−log₂ p`. */
|
|
51
|
+
readonly formula?: Readonly<Record<string, string>> | undefined;
|
|
52
|
+
/** The pixel box of each value. Defaults to `flowNodeSize`. */
|
|
53
|
+
readonly size?: {
|
|
54
|
+
readonly width: number;
|
|
55
|
+
readonly height: number;
|
|
56
|
+
} | undefined;
|
|
57
|
+
/** The hue of the pulse that shows a change. Left out, ink. */
|
|
58
|
+
readonly tone?: ChartTone | undefined;
|
|
59
|
+
readonly labels?: Partial<SceneFlowLabels> | undefined;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A lesson's derivation drawn live inside a `Scene`: each param and derived value is a node in layers left to right,
|
|
63
|
+
* wired to the values it reads. Params are inline controls, every value shows its current text, and a change glows
|
|
64
|
+
* through what it touched. Inspecting a value lights what it reads and what reads it.
|
|
65
|
+
*/
|
|
66
|
+
export declare function SceneFlow({ lesson, names, layout, at, formula, size, tone, labels: labelInput, }: SceneFlowProps): ReactNode;
|
|
67
|
+
export type LessonFlowProps = Omit<SceneProps, 'x' | 'y' | 'title' | 'height' | 'aspect' | 'children' | 'labels'> & Omit<SceneFlowProps, 'at' | 'labels'> & {
|
|
68
|
+
/** The flow's words and the scene's words in one object. */
|
|
69
|
+
readonly labels?: (Partial<SceneFlowLabels> & Partial<SceneLabels>) | undefined;
|
|
70
|
+
/** Left out, the lesson's title. */
|
|
71
|
+
readonly title?: string | undefined;
|
|
72
|
+
/** Left out, the smallest named height whose columns hold the flow's busiest layer. */
|
|
73
|
+
readonly height?: PlotHeight | undefined;
|
|
74
|
+
/** More scene parts drawn with the flow, such as a `SceneCallout` on one of its values. */
|
|
75
|
+
readonly children?: ReactNode;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* A lesson's derivation as a figure of its own: a `Scene` sized to the flow, with `SceneFlow` inside. Use it beside the
|
|
79
|
+
* prose and controls of a lesson; the author supplies only a title and description, or nothing.
|
|
80
|
+
*/
|
|
81
|
+
export declare function LessonFlow({ lesson, names, layout, formula, size, tone, labels, title, height, children, ...scene }: LessonFlowProps): ReactNode;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagrams with identity. A `Scene` places nodes, wires, notes, plane marks, cards, cells and tokens in a data box on
|
|
3
|
+
* the plot kernel; change their props and they ease to the new state. New parts build on `useSceneObject`.
|
|
4
|
+
*/
|
|
5
|
+
export type { SceneProps } from './scene.tsx';
|
|
6
|
+
export { Scene } from './scene.tsx';
|
|
7
|
+
export type { SceneNodeProps } from './scene-node.tsx';
|
|
8
|
+
export { SceneNode } from './scene-node.tsx';
|
|
9
|
+
export type { SceneWireProps, SceneWireShape, SceneWireTextSide } from './scene-wire.tsx';
|
|
10
|
+
export { SceneWire } from './scene-wire.tsx';
|
|
11
|
+
export type { SceneGroupProps } from './scene-group.tsx';
|
|
12
|
+
export { SceneGroup } from './scene-group.tsx';
|
|
13
|
+
export type { SceneBracketProps, SceneBracketSide } from './scene-bracket.tsx';
|
|
14
|
+
export { SceneBracket } from './scene-bracket.tsx';
|
|
15
|
+
export type { SceneCalloutProps, SceneCalloutSide } from './scene-callout.tsx';
|
|
16
|
+
export { SceneCallout } from './scene-callout.tsx';
|
|
17
|
+
export type { SceneHighlightProps } from './scene-highlight.tsx';
|
|
18
|
+
export { SceneHighlight } from './scene-highlight.tsx';
|
|
19
|
+
export type { SceneCustomProps, SceneDrawing } from './scene-custom.tsx';
|
|
20
|
+
export { SceneCustom } from './scene-custom.tsx';
|
|
21
|
+
export type { SceneLayerName } from './scene-layer.tsx';
|
|
22
|
+
export { SceneLayer, SceneOutside } from './scene-layer.tsx';
|
|
23
|
+
export type { SceneContextValue, SceneFollowed, SceneObjectInput, SceneObjectState } from './scene-context.ts';
|
|
24
|
+
export { useSceneContext, useSceneFrames, useSceneObject } from './scene-context.ts';
|
|
25
|
+
export type { SceneDelay, SceneStagger, SceneStaggerPlace } from './scene-stagger.ts';
|
|
26
|
+
export { sceneStaggers } from './scene-stagger.ts';
|
|
27
|
+
export type { SceneDataPoint, SceneFrame, SceneMargins, SceneOffset, ScenePixel, ScenePosition, SceneRect, SceneShape, SceneSize, SceneSizeName, SceneView, } from './scene-geometry.ts';
|
|
28
|
+
export { edgePoint, nodeBox, padRect, rectCenter, rectsOverlap, sceneCircleSizes, sceneNodeSizes, sidePoint, unionRect, } from './scene-geometry.ts';
|
|
29
|
+
export { useObstacle } from './scene-obstacles.ts';
|
|
30
|
+
export type { SceneFrameKey, SceneFrameValues, SceneMember, SceneRegistry, SceneTrack } from './scene-registry.ts';
|
|
31
|
+
export { sceneStore } from './scene-registry.ts';
|
|
32
|
+
export type { SceneOutlineState } from './scene-style.ts';
|
|
33
|
+
export { sceneContextColor, sceneOutlines } from './scene-style.ts';
|
|
34
|
+
export type { SceneLabels } from './scene-validate.ts';
|
|
35
|
+
export { fillLabel, sceneLabels, sceneLimits } from './scene-validate.ts';
|
|
36
|
+
export type { SceneAxesProps, SceneAxis } from './plane/scene-axes.tsx';
|
|
37
|
+
export { SceneAxes } from './plane/scene-axes.tsx';
|
|
38
|
+
export type { SceneCurveProps } from './plane/scene-curve.tsx';
|
|
39
|
+
export { SceneCurve } from './plane/scene-curve.tsx';
|
|
40
|
+
export type { ScenePointAlong, ScenePointMoveDetails, ScenePointProps, ScenePointSets } from './plane/scene-point.tsx';
|
|
41
|
+
export { ScenePoint } from './plane/scene-point.tsx';
|
|
42
|
+
export type { SceneProjectionProps } from './plane/scene-projection.tsx';
|
|
43
|
+
export { SceneProjection } from './plane/scene-projection.tsx';
|
|
44
|
+
export type { SceneRegionProps } from './plane/scene-region.tsx';
|
|
45
|
+
export { SceneRegion } from './plane/scene-region.tsx';
|
|
46
|
+
export type { SceneRuleProps } from './plane/scene-rule.tsx';
|
|
47
|
+
export { SceneRule } from './plane/scene-rule.tsx';
|
|
48
|
+
export type { SceneVectorProps } from './plane/scene-vector.tsx';
|
|
49
|
+
export { SceneVector } from './plane/scene-vector.tsx';
|
|
50
|
+
export type { ScenePlaneLabels } from './plane/plane-labels.ts';
|
|
51
|
+
export { planeLabels } from './plane/plane-labels.ts';
|
|
52
|
+
export type { SceneCurveResolution, ScenePlaneThickness } from './plane/plane-math.ts';
|
|
53
|
+
export { curveResolutions, planeLimits, planeThicknesses } from './plane/plane-math.ts';
|
|
54
|
+
export type { CardRank, CardSuit, SceneCardLabels, SceneCardProps } from './shapes/scene-card.tsx';
|
|
55
|
+
export { cardRanks, cardSuits, SceneCard, sceneCardLabels, suitTones } from './shapes/scene-card.tsx';
|
|
56
|
+
export type { SceneStackLabels, SceneStackProps } from './shapes/scene-stack.tsx';
|
|
57
|
+
export { SceneStack, sceneStackLabels } from './shapes/scene-stack.tsx';
|
|
58
|
+
export type { SceneSlotProps } from './shapes/scene-slot.tsx';
|
|
59
|
+
export { SceneSlot } from './shapes/scene-slot.tsx';
|
|
60
|
+
export type { SceneCardSizeName, StackBounds, StackGapName, StackLayout, StackPlace, StackShape, } from './shapes/stack-layout.ts';
|
|
61
|
+
export { sceneCardSizes, stackBounds, stackGaps, stackPlace } from './shapes/stack-layout.ts';
|
|
62
|
+
export type { SceneCellsLabels, SceneCellsProps } from './shapes/scene-cells.tsx';
|
|
63
|
+
export { SceneCells, sceneCellsLabels } from './shapes/scene-cells.tsx';
|
|
64
|
+
export type { SceneCellInput, SceneCellsDirection, SceneCellSizeName, SceneCellValues } from './shapes/cell-grid.ts';
|
|
65
|
+
export { cellGap, sceneCellSizes } from './shapes/cell-grid.ts';
|
|
66
|
+
export type { SceneTokenLabels, SceneTokenProps } from './shapes/scene-token.tsx';
|
|
67
|
+
export { SceneToken, sceneTokenLabels, tokenPercent } from './shapes/scene-token.tsx';
|
|
68
|
+
export type { SceneTokenItem, SceneTokensProps } from './shapes/scene-tokens.tsx';
|
|
69
|
+
export { SceneTokens } from './shapes/scene-tokens.tsx';
|
|
70
|
+
export type { TokenFlow, TokenGapName } from './shapes/token-layout.ts';
|
|
71
|
+
export { tokenBox, tokenFlow, tokenGaps } from './shapes/token-layout.ts';
|
|
72
|
+
export type { LessonFlowProps, SceneFlowLabels, SceneFlowProps } from './flow/scene-flow.tsx';
|
|
73
|
+
export { flowNodeSize, LessonFlow, SceneFlow, sceneFlowLabels } from './flow/scene-flow.tsx';
|
|
74
|
+
export type { FlowDirection, FlowPlan, FlowSlot } from './flow/flow-layout.ts';
|
|
75
|
+
export { flowPlan, flowPositions } from './flow/flow-layout.ts';
|
|
76
|
+
export type { MorphLabels, MorphScopeProps } from './morph/morph-scope.tsx';
|
|
77
|
+
export { morphLabels, MorphScope } from './morph/morph-scope.tsx';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { Pace } from '../../time/tween.ts';
|
|
4
|
+
/** The words a morph shows that are not the author's content. */
|
|
5
|
+
export type MorphLabels = {
|
|
6
|
+
/** `{name}` is the figure `show` names, `{names}` the figures given. */
|
|
7
|
+
readonly unknownFigure: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const morphLabels: {
|
|
10
|
+
readonly unknownFigure: 'MorphScope shows "{name}", which is not one of its figures: {names}.';
|
|
11
|
+
};
|
|
12
|
+
export type MorphScopeProps<Name extends string> = {
|
|
13
|
+
/** The figures by name. Each stays mounted and keeps its state while another is shown. */
|
|
14
|
+
readonly figures: Readonly<Record<Name, ReactNode>>;
|
|
15
|
+
/** The figure on screen. Change it and every thing both figures draw travels to its place in the new one. */
|
|
16
|
+
readonly show: Name;
|
|
17
|
+
/** How fast the figures trade places. Defaults to `slow`. Reduced motion swaps at once. */
|
|
18
|
+
readonly pace?: Pace | undefined;
|
|
19
|
+
/** The hue of each thing's travelling shape, by id. Left out, the tone scope's, or neutral. */
|
|
20
|
+
readonly tones?: Readonly<Record<string, ChartTone>> | undefined;
|
|
21
|
+
readonly labels?: Partial<MorphLabels> | undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Two or more figures that show the same things, one at a time. When `show` changes, each thing drawn in both, matched
|
|
25
|
+
* by id, travels from its place in the old figure to its place in the new one while the figures cross-fade. Use it when
|
|
26
|
+
* a card becomes a bar, or a neuron a dot: the author names the figure to show and nothing else.
|
|
27
|
+
*/
|
|
28
|
+
export declare function MorphScope<Name extends string>({ figures, show, pace, tones, labels: labelInput, }: MorphScopeProps<Name>): ReactNode;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { SceneLayerName } from '../scene-layer.tsx';
|
|
3
|
+
/** Draws plane marks into one scene layer, faded to the part's own opacity. Nothing is drawn outside a scene. */
|
|
4
|
+
export declare function PlaneMarks({ id, layer, opacity, children, }: {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly layer: SceneLayerName;
|
|
7
|
+
readonly opacity: number;
|
|
8
|
+
readonly children: ReactNode;
|
|
9
|
+
}): ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* The part of a mark a pointer can reach and the keyboard cursor's dashed edge. A part with a label is an item the
|
|
12
|
+
* reader inspects, so its path takes pointer events; the cursor draws along the same path.
|
|
13
|
+
*/
|
|
14
|
+
export declare function PlaneHit({ id, d, hasLabel, isCursor, reach, }: {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
/** The SVG path of the mark. */
|
|
17
|
+
readonly d: string;
|
|
18
|
+
readonly hasLabel: boolean;
|
|
19
|
+
readonly isCursor: boolean;
|
|
20
|
+
/** `stroke` for a line, `fill` for a region. */
|
|
21
|
+
readonly reach?: 'stroke' | 'fill' | undefined;
|
|
22
|
+
}): ReactNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LabelObstacle, LabelSpot } from '../../../../charts/src/plot/index.ts';
|
|
3
|
+
/** The places a label may go around a mark at a position, in order of preference: beside it, then above or below. */
|
|
4
|
+
export declare function spotsAround({ x, y, text, }: {
|
|
5
|
+
readonly x: number;
|
|
6
|
+
readonly y: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}): ReadonlyArray<LabelSpot>;
|
|
9
|
+
/**
|
|
10
|
+
* A part's short text in the plot. It takes the first of `spots` that stays inside the plot and touches no other part
|
|
11
|
+
* and no label placed before it. Failing that, it takes the one that touches least.
|
|
12
|
+
*/
|
|
13
|
+
export declare function PlaneLabel({ owner, name, spots, lines, isStrong, }: {
|
|
14
|
+
/** The id of the part the text belongs to. Its own lines are not avoided; pass the ones to avoid in `lines`. */
|
|
15
|
+
readonly owner: string;
|
|
16
|
+
/** Tells apart the labels of one part. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Where the text may go, in order of preference. */
|
|
19
|
+
readonly spots: ReadonlyArray<LabelSpot>;
|
|
20
|
+
/** Extra lines to keep clear of, in plot pixels. A single point stands for a dot. */
|
|
21
|
+
readonly lines?: ReadonlyArray<ReadonlyArray<LabelObstacle>> | undefined;
|
|
22
|
+
readonly isStrong?: boolean | undefined;
|
|
23
|
+
}): ReactNode;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** The words the plane parts show that are not the author's content. Placeholders in braces are filled in. */
|
|
2
|
+
export type ScenePlaneLabels = {
|
|
3
|
+
/** `{id}` names the curve. */
|
|
4
|
+
readonly curveSource: string;
|
|
5
|
+
/** `{id}` names the curve, `{limit}` is the most points one curve takes. */
|
|
6
|
+
readonly curveTooMany: string;
|
|
7
|
+
/** `{id}` names the curve. */
|
|
8
|
+
readonly curveOrder: string;
|
|
9
|
+
/** `{id}` names the curve and `{x}` the position where the function gave a value that is not a number. */
|
|
10
|
+
readonly curveValue: string;
|
|
11
|
+
/** `{id}` names the point. */
|
|
12
|
+
readonly pointLabel: string;
|
|
13
|
+
/** `{id}` names the point that sets lesson params outside any `Lesson`. */
|
|
14
|
+
readonly pointOutsideLesson: string;
|
|
15
|
+
/** `{id}` names the point, `{name}` the param and `{lesson}` the lesson that does not declare it as a number. */
|
|
16
|
+
readonly pointParam: string;
|
|
17
|
+
/** Added after a movable point's label in the readout. */
|
|
18
|
+
readonly pointMovable: string;
|
|
19
|
+
/** `{id}` names the region. */
|
|
20
|
+
readonly regionShape: string;
|
|
21
|
+
/** `{id}` names the rule. */
|
|
22
|
+
readonly ruleAxis: string;
|
|
23
|
+
/** `{id}` names the projection. */
|
|
24
|
+
readonly projectionSource: string;
|
|
25
|
+
/** `{kind}` and `{id}` name the part whose value is not a finite number. */
|
|
26
|
+
readonly notFinite: string;
|
|
27
|
+
};
|
|
28
|
+
/** The plain English defaults of `ScenePlaneLabels`. */
|
|
29
|
+
export declare const planeLabels: {
|
|
30
|
+
readonly curveSource: 'The curve "{id}" needs `points` or `of`, and not both.';
|
|
31
|
+
readonly curveTooMany: 'The curve "{id}" takes at most {limit} points. Pass fewer, or use `of`.';
|
|
32
|
+
readonly curveOrder: 'The curve "{id}" needs at least two points with strictly increasing x.';
|
|
33
|
+
readonly curveValue: 'The curve "{id}" gives a value that is not a number at x = {x}.';
|
|
34
|
+
readonly pointLabel: 'The point "{id}" can be moved, so it needs a `label` for the readout.';
|
|
35
|
+
readonly pointOutsideLesson: 'The point "{id}" sets lesson params, so it must be inside a Lesson.';
|
|
36
|
+
readonly pointParam: 'The point "{id}" sets "{name}", which lesson "{lesson}" does not declare as a number param.';
|
|
37
|
+
readonly pointMovable: ' Use the arrow keys to move it.';
|
|
38
|
+
readonly regionShape: 'The region "{id}" needs one of `between`, `above`, `below` or `points`.';
|
|
39
|
+
readonly ruleAxis: 'The rule "{id}" needs `x` or `y`, and not both.';
|
|
40
|
+
readonly projectionSource: 'The projection "{id}" needs `of` or `at`, and not both.';
|
|
41
|
+
readonly notFinite: 'The {kind} "{id}" has a value that is not a finite number.';
|
|
42
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { NumericDomain } from '../../../../charts/src/index.ts';
|
|
2
|
+
import type { SceneDataPoint, ScenePosition } from '../scene-geometry.ts';
|
|
3
|
+
/** How many samples a function curve takes across the whole data box, by name. */
|
|
4
|
+
export declare const curveResolutions: {
|
|
5
|
+
readonly coarse: 60;
|
|
6
|
+
readonly regular: 160;
|
|
7
|
+
readonly fine: 400;
|
|
8
|
+
};
|
|
9
|
+
/** How finely a function curve is sampled. Use `fine` for a curve the camera zooms into. */
|
|
10
|
+
export type SceneCurveResolution = keyof typeof curveResolutions;
|
|
11
|
+
/** The most points one curve or polygon takes. Larger input shows an error. */
|
|
12
|
+
export declare const planeLimits: {
|
|
13
|
+
readonly curvePoints: 2000;
|
|
14
|
+
readonly polygonPoints: 200;
|
|
15
|
+
};
|
|
16
|
+
/** How thick a curve or vector is drawn. */
|
|
17
|
+
export type ScenePlaneThickness = 'thin' | 'regular' | 'thick';
|
|
18
|
+
/** The stroke width of each named thickness, in pixels. */
|
|
19
|
+
export declare const planeThicknesses: {
|
|
20
|
+
readonly thin: 1.25;
|
|
21
|
+
readonly regular: 1.75;
|
|
22
|
+
readonly thick: 3;
|
|
23
|
+
};
|
|
24
|
+
/** The scene's data box. */
|
|
25
|
+
export type DataBox = {
|
|
26
|
+
readonly x: NumericDomain;
|
|
27
|
+
readonly y: NumericDomain;
|
|
28
|
+
};
|
|
29
|
+
/** A value held between the two ends of a domain. A value that is not a number lands in the middle. */
|
|
30
|
+
export declare function insideDomain(value: number, domain: NumericDomain): number;
|
|
31
|
+
/** A position held inside the data box. */
|
|
32
|
+
export declare function insideBox(position: ScenePosition, box: DataBox): ScenePosition;
|
|
33
|
+
/** `count` evenly spaced values from one end of the domain to the other. */
|
|
34
|
+
export declare function gridXs(domain: NumericDomain, count: number): ReadonlyArray<number>;
|
|
35
|
+
/** The y of a polyline at `x`, holding the first and last values beyond its ends. Points increase in x. */
|
|
36
|
+
export declare function interpolateAt(points: ReadonlyArray<ScenePosition>, across: number): number;
|
|
37
|
+
/** The part of a sampled curve that lies between `from` and `to`, with a vertex exactly at each end. */
|
|
38
|
+
export declare function visibleRun({ xs, ys, from, to, }: {
|
|
39
|
+
readonly xs: ReadonlyArray<number>;
|
|
40
|
+
readonly ys: ReadonlyArray<number>;
|
|
41
|
+
readonly from: number;
|
|
42
|
+
readonly to: number;
|
|
43
|
+
}): ReadonlyArray<SceneDataPoint>;
|
|
44
|
+
/** The mean of a polygon's corners, which is a fair place for its name and for a keyboard cursor. */
|
|
45
|
+
export declare function centroid(corners: ReadonlyArray<SceneDataPoint>): SceneDataPoint;
|