@mechane-ai/elements 0.47.0 → 0.49.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/ai.js +5 -5
- package/dist/article-yyNPg6VU.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +1691 -163
- package/dist/{categorical-values-DdfGIowV.js → categorical-values-DCznViFp.js} +1 -1
- package/dist/{cells--Bd1fQFR.js → cells-CNZE4us2.js} +2 -2
- 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 +6 -6
- 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/{code-block-DioAM2bZ.js → code-block-BZsY2sh3.js} +1 -1
- package/dist/collections.js +1 -1
- package/dist/content/code.js +1 -1
- package/dist/content/diff.js +3 -3
- package/dist/content/link.js +1 -1
- package/dist/content/markdown.js +2 -2
- package/dist/content/tree.js +1 -1
- package/dist/{content-link-NWuHp5rC.js → content-link-PnpcnTCx.js} +1 -1
- package/dist/content.js +1 -1
- package/dist/{dates-Cww8UR_n.js → dates-ckJdYF7t.js} +1 -1
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-CMv9llfd.js} +9 -7
- package/dist/{embedding-map-CGM_k6lC.js → embedding-map-DC-lgzCq.js} +8 -8
- package/dist/feedback.js +1 -1
- package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BjFzbl3m.js} +3 -3
- package/dist/forms/dates.js +1 -1
- package/dist/forms.js +3 -3
- package/dist/{image-grid-CVA4SOy_.js → image-grid-DHqtj_zs.js} +4 -4
- package/dist/index.js +1 -1
- package/dist/kits/evaluation.js +5 -5
- package/dist/kits/interpretability.js +320 -302
- package/dist/kits/operations.js +6 -6
- package/dist/kits/research.js +558 -0
- package/dist/kits/training.js +6 -6
- package/dist/layout.js +205 -110
- 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/navigation.js +2 -2
- package/dist/packages/charts/src/cartesian/index.d.ts +1 -1
- package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +18 -0
- package/dist/packages/charts/src/chart-theme.d.ts +1 -1
- 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/charts/src/plot/plot-surface.d.ts +3 -1
- package/dist/packages/collections/src/index.d.ts +1 -1
- package/dist/packages/collections/src/metrics.d.ts +9 -1
- package/dist/packages/content/src/index.d.ts +2 -0
- package/dist/packages/content/src/text-match.d.ts +22 -0
- package/dist/packages/core/src/index.d.ts +1 -0
- package/dist/packages/core/src/surfaces.d.ts +12 -2
- package/dist/packages/forms/src/index.d.ts +2 -0
- package/dist/packages/forms/src/token-input.d.ts +24 -0
- package/dist/packages/kits/src/interpretability/index.d.ts +1 -1
- package/dist/packages/kits/src/interpretability/logit-lens.d.ts +10 -1
- package/dist/packages/kits/src/research/finding-card.d.ts +43 -0
- package/dist/packages/kits/src/research/index.d.ts +8 -0
- package/dist/packages/kits/src/research/milestone-path.d.ts +36 -0
- package/dist/packages/kits/src/research/specimen-diff.d.ts +41 -0
- package/dist/packages/kits/src/research/work-heartbeat.d.ts +34 -0
- package/dist/packages/layout/src/figure-grid.d.ts +8 -0
- package/dist/packages/layout/src/index.d.ts +4 -1
- package/dist/packages/layout/src/sidebar.d.ts +7 -0
- package/dist/packages/layout/src/workbench.d.ts +4 -1
- 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-BE3VMSkH.js +450 -0
- package/dist/{pierre-diff-DlvjyuJn.js → pierre-diff-aGyQK5xK.js} +1 -1
- package/dist/{plot-axes-DJkLW4wk.js → plot-axes-D5S9BnBa.js} +1 -1
- package/dist/{plot-layout-BEuoOHbs.js → plot-layout-Bqe4-0qZ.js} +4 -3
- package/dist/{plot-marks-A64v7aTw.js → plot-marks-FVsbFkUs.js} +18 -15
- package/dist/{plot-surface-CJTIqtck.js → plot-surface-DON6WUmk.js} +11 -11
- package/dist/{plot-width-DcqtSgzb.js → plot-width-D3hTycYX.js} +1 -1
- package/dist/{reference-lines-CWA8VeUR.js → reference-lines-hjuD1rRZ.js} +2 -2
- package/dist/scene-BP0Ue0R5.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/{slope-chart-DT22h_ym.js → slope-chart-C8eeSgL4.js} +7 -7
- package/dist/{src-CpdJlDhO.js → src-9EJskqB_.js} +73 -31
- package/dist/{src-D5NXRJZe.js → src-B2rgpWap.js} +48 -14
- package/dist/{src-BPTDJqt0.js → src-Ci8DeY8J.js} +1 -1
- package/dist/{src-CGc_hjxJ.js → src-DFW49IAs.js} +143 -111
- package/dist/{src-1EHkSFS-.js → src-Dxs3Buo_.js} +205 -139
- package/dist/{src-CExIrXPC.js → src-npqwq3Sa.js} +1 -1
- package/dist/styles2.css +542 -21
- package/dist/{time-series-IB3CB93O.js → time-series-BL933QyA.js} +787 -715
- package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BB65awva.js} +4 -4
- package/dist/{token-predictions-Cxx29iDr.js → token-predictions-Pa8eUGan.js} +6 -6
- package/dist/transport-DzyxVXbL.js +715 -0
- package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-DJhKBiia.js} +6 -6
- package/dist/{treemap-9_DpLCW9.js → treemap-CxxgABUg.js} +5 -5
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/{violin-plot-BhPHKXsN.js → violin-plot-CoAEF_7Z.js} +7 -6
- package/dist/{waterfall-CGksuTy5.js → waterfall-DdoEXEkT.js} +7 -7
- package/package.json +30 -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 +9 -26
- 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,18 @@
|
|
|
1
|
+
import type { ArticleView } from './article-context.ts';
|
|
2
|
+
import type { ArticleOutline, OutlineBeat } from './outline-types.ts';
|
|
3
|
+
/** Where a beat stands at a lesson step: the scrolly step it shows, if any, and its reveal step. */
|
|
4
|
+
export type BeatPlace = {
|
|
5
|
+
readonly scrolly: number | null;
|
|
6
|
+
readonly reveal: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Splits a lesson step into a scrolly step and a reveal step. In the present view a beat walks its scrolly steps first,
|
|
10
|
+
* then its declared reveal steps; the other views count reveal steps alone, since scrolling walks a scrolly.
|
|
11
|
+
*/
|
|
12
|
+
export declare function beatPlace({ beat, step, view, }: {
|
|
13
|
+
readonly beat: OutlineBeat | undefined;
|
|
14
|
+
readonly step: number;
|
|
15
|
+
readonly view: ArticleView;
|
|
16
|
+
}): BeatPlace;
|
|
17
|
+
/** The steps each beat's scrollies add to the lesson: one fewer than they have, as step 0 shows one. */
|
|
18
|
+
export declare function scrollyAddedSteps(outline: ArticleOutline): Readonly<Record<string, number>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AnyLesson, LessonBeat } from '../lesson/define-lesson.ts';
|
|
3
|
+
export type BeatProps = {
|
|
4
|
+
/** The id of a beat the lesson declares. Its title, tutor notes, reveal steps and states come from there. */
|
|
5
|
+
readonly id: string;
|
|
6
|
+
/** The beat's prose, figures and exercises. */
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/** The beat a lesson declares under `id`, or undefined. */
|
|
10
|
+
export declare function lessonBeat(lesson: AnyLesson, id: string): LessonBeat | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* One beat of an essay: a titled section whose title, tutor notes, reveal steps and states the lesson declares. The
|
|
13
|
+
* article view scrolls through every beat, the present view shows the current one, and the static view opens each at
|
|
14
|
+
* its first state. Tutor notes are never shown to the reader.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Beat({ id, children }: BeatProps): ReactNode;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LessonValue } from '../lesson/define-lesson.ts';
|
|
3
|
+
/** The words of a challenge. The hint button reads "Show a hint (1 of 3)": `hint`, then `of`. */
|
|
4
|
+
export type ChallengeLabels = {
|
|
5
|
+
readonly kicker: string;
|
|
6
|
+
readonly reached: string;
|
|
7
|
+
readonly notYet: string;
|
|
8
|
+
readonly hint: string;
|
|
9
|
+
readonly of: string;
|
|
10
|
+
readonly showOutcome: string;
|
|
11
|
+
};
|
|
12
|
+
export type ChallengeProps = {
|
|
13
|
+
/** The challenge's id, unique in the article. The reader's progress records it under this id. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** The task, such as "Make the top token at least 90% likely". */
|
|
16
|
+
readonly prompt: ReactNode;
|
|
17
|
+
/** Whether the lesson's values meet the task. It reads params and derived values by name. */
|
|
18
|
+
readonly isReached: (values: Readonly<Record<string, LessonValue>>) => boolean;
|
|
19
|
+
/** Hints the reader can ask for, one at a time. */
|
|
20
|
+
readonly hints?: ReadonlyArray<string> | undefined;
|
|
21
|
+
/** What the reader finds, shown once the challenge is reached. */
|
|
22
|
+
readonly children: ReactNode;
|
|
23
|
+
readonly labels?: Partial<ChallengeLabels> | undefined;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A task the reader meets by changing the lesson's values: once a change of their own makes `isReached` true, the
|
|
27
|
+
* challenge counts as reached and shows its outcome. A change an agent makes never reaches it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function Challenge({ id, prompt, isReached, hints, children, labels }: ChallengeProps): ReactNode;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as stylex from '@stylexjs/stylex';
|
|
2
|
+
/** The look `Predict` and `Challenge` share: a quiet panel in the text column, with a kicker above the question. */
|
|
3
|
+
export declare const exerciseStyles: Readonly<{
|
|
4
|
+
readonly box: Readonly<{
|
|
5
|
+
readonly display: stylex.StyleXClassNameFor<"display", "grid">;
|
|
6
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
7
|
+
readonly marginBlock: stylex.StyleXClassNameFor<"marginBlock", string>;
|
|
8
|
+
readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
|
|
9
|
+
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
|
|
10
|
+
readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
|
|
11
|
+
readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
|
|
12
|
+
readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string>;
|
|
13
|
+
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
|
14
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
|
|
15
|
+
readonly breakInside: stylex.StyleXClassNameFor<"breakInside", "avoid">;
|
|
16
|
+
}>;
|
|
17
|
+
readonly kicker: Readonly<{
|
|
18
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
19
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
20
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
21
|
+
readonly lineHeight: stylex.StyleXClassNameFor<"lineHeight", string>;
|
|
22
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
23
|
+
readonly letterSpacing: stylex.StyleXClassNameFor<"letterSpacing", "0.06em">;
|
|
24
|
+
readonly textTransform: stylex.StyleXClassNameFor<"textTransform", "uppercase">;
|
|
25
|
+
}>;
|
|
26
|
+
readonly prompt: Readonly<{
|
|
27
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
28
|
+
}>;
|
|
29
|
+
readonly meta: Readonly<{
|
|
30
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
31
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
32
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
33
|
+
}>;
|
|
34
|
+
readonly controls: Readonly<{
|
|
35
|
+
readonly display: stylex.StyleXClassNameFor<"display", "grid">;
|
|
36
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
37
|
+
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "28rem">;
|
|
38
|
+
}>;
|
|
39
|
+
readonly result: Readonly<{
|
|
40
|
+
readonly display: stylex.StyleXClassNameFor<"display", "grid">;
|
|
41
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
42
|
+
}>;
|
|
43
|
+
readonly verdict: Readonly<{
|
|
44
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
45
|
+
}>;
|
|
46
|
+
readonly right: Readonly<{
|
|
47
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
48
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
49
|
+
}>;
|
|
50
|
+
readonly wrong: Readonly<{
|
|
51
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
52
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
53
|
+
}>;
|
|
54
|
+
readonly details: Readonly<{
|
|
55
|
+
readonly display: stylex.StyleXClassNameFor<"display", "grid">;
|
|
56
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
57
|
+
}>;
|
|
58
|
+
readonly summary: Readonly<{
|
|
59
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
60
|
+
readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer">;
|
|
61
|
+
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
|
|
62
|
+
}>;
|
|
63
|
+
readonly hints: Readonly<{
|
|
64
|
+
readonly display: stylex.StyleXClassNameFor<"display", "grid">;
|
|
65
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
66
|
+
readonly margin: stylex.StyleXClassNameFor<"margin", 0>;
|
|
67
|
+
readonly paddingInlineStart: stylex.StyleXClassNameFor<"paddingInlineStart", string>;
|
|
68
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
69
|
+
}>;
|
|
70
|
+
readonly actions: Readonly<{
|
|
71
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex">;
|
|
72
|
+
readonly flexWrap: stylex.StyleXClassNameFor<"flexWrap", "wrap">;
|
|
73
|
+
readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
|
|
74
|
+
readonly gap: stylex.StyleXClassNameFor<"gap", string>;
|
|
75
|
+
}>;
|
|
76
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** True inside a repeated copy of a figure, such as a scrolly's figure at each step, so only the first keeps its id. */
|
|
3
|
+
export declare const FigureCopy: import("react").Context<boolean>;
|
|
4
|
+
/** True inside a part that already sets its figure's width, such as a scrolly, so the figure never widens again. */
|
|
5
|
+
export declare const FigureColumn: import("react").Context<boolean>;
|
|
6
|
+
/** How wide a figure is: the text column, or the text and its margin on wide screens. */
|
|
7
|
+
export type FigureSize = 'text' | 'wide';
|
|
8
|
+
export type FigureProps = {
|
|
9
|
+
/** The figure's id, unique in the article. It is the element id, so `#id` links land on the figure. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** What the reader should see in the figure, after its number. */
|
|
12
|
+
readonly caption: ReactNode;
|
|
13
|
+
/** The figure in words, for a reader who cannot see it. The static view prints it after the figure. */
|
|
14
|
+
readonly description?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The lesson values the figure reads, when its markup does not name them through `Param`, `Value` or a control. The
|
|
17
|
+
* beat sheet uses them to find prose controls that change no figure.
|
|
18
|
+
*/
|
|
19
|
+
readonly reads?: ReadonlyArray<string> | undefined;
|
|
20
|
+
/** Wide figures, the default, reach into the margin column on wide screens. */
|
|
21
|
+
readonly size?: FigureSize | undefined;
|
|
22
|
+
/** The chart, scene or image. */
|
|
23
|
+
readonly children: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A chart, scene or image with its number and caption: "Figure 2. Lower temperatures sharpen the distribution." Figures
|
|
27
|
+
* are numbered in reading order. Give each a `description` so the static view and assistive technology can say what it
|
|
28
|
+
* shows.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Figure({ id, caption, description, size, children }: FigureProps): ReactNode;
|
|
31
|
+
export type FigureReferenceProps = {
|
|
32
|
+
/** The id of the figure the reference points to. */
|
|
33
|
+
readonly to: string;
|
|
34
|
+
};
|
|
35
|
+
/** "Figure 2" in prose, as a link that moves the reader to that figure. An unknown id shows an error in its place. */
|
|
36
|
+
export declare function FigureReference({ to }: FigureReferenceProps): ReactNode;
|
|
37
|
+
export type RevealProps = {
|
|
38
|
+
/** The reveal step of the beat from which this content shows, counted from 0. */
|
|
39
|
+
readonly at: number;
|
|
40
|
+
readonly children: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Whether reveal step `at` of the surrounding beat shows now, for a figure that reveals its own parts. It is true in
|
|
44
|
+
* the article, static and sheet views and outside a beat; in the present view it follows the beat's reveal step.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useRevealed(at: number): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Content that appears at a reveal step of its beat in the present view, where Right or Space shows the next step. The
|
|
49
|
+
* article and static views show it at once, so a scrolling reader and a printed page lose nothing.
|
|
50
|
+
*/
|
|
51
|
+
export declare function Reveal({ at, children }: RevealProps): ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrative structure for explorable essays. An `Article` renders a lesson as beats of prose, figures and exercises,
|
|
3
|
+
* and arranges the same children as a scrolling essay, a presentation, a static page or a beat sheet.
|
|
4
|
+
*/
|
|
5
|
+
export type { ArticleProps } from './article.tsx';
|
|
6
|
+
export { Article } from './article.tsx';
|
|
7
|
+
export type { ArticleMath, ArticleView } from './article-context.ts';
|
|
8
|
+
export type { ArticleLabels } from './article-labels.ts';
|
|
9
|
+
export { defaultArticleLabels } from './article-labels.ts';
|
|
10
|
+
export type { ArticleFinding } from './article-checks.ts';
|
|
11
|
+
export { articleChecks } from './article-checks.ts';
|
|
12
|
+
export { answerSources, articleOutline } from './article-outline.ts';
|
|
13
|
+
export type { BeatProps } from './beat.tsx';
|
|
14
|
+
export { Beat } from './beat.tsx';
|
|
15
|
+
export type { FigureProps, FigureReferenceProps, FigureSize, RevealProps } from './figure.tsx';
|
|
16
|
+
export { Figure, FigureReference, Reveal, useRevealed } from './figure.tsx';
|
|
17
|
+
export type { AsideProps, CiteProps, FootnoteProps, ReferencesProps } from './notes.tsx';
|
|
18
|
+
export type { ArticleOutline, OutlineBeat, OutlineFigure, OutlinePrediction, ReferenceItem } from './outline-types.ts';
|
|
19
|
+
export { Aside, Cite, Footnote, References } from './notes.tsx';
|
|
20
|
+
export type { TeXProps } from './tex.tsx';
|
|
21
|
+
export { TeX } from './tex.tsx';
|
|
22
|
+
export type { DiagramPartProps, TermLabels, TermProps } from './term.tsx';
|
|
23
|
+
export { DiagramPart, Term } from './term.tsx';
|
|
24
|
+
export type { ScrollyProps, ScrollyStepProps } from './scrolly.tsx';
|
|
25
|
+
export { Scrolly, ScrollyStep } from './scrolly.tsx';
|
|
26
|
+
export type { ChoicePrediction, NumberPrediction, PredictLabels, PredictProps } from './predict.tsx';
|
|
27
|
+
export { Predict } from './predict.tsx';
|
|
28
|
+
export type { ChallengeLabels, ChallengeProps } from './challenge.tsx';
|
|
29
|
+
export { Challenge } from './challenge.tsx';
|
|
30
|
+
export type { LessonProgress, PredictionRecord, ProgressChangeDetails, ProgressChangeReason, } from './progress-store.ts';
|
|
31
|
+
export { emptyProgress } from './progress-store.ts';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyLesson, LessonValue } from '../lesson/define-lesson.ts';
|
|
2
|
+
/** The first problem with values an author wrote for a lesson, such as a name it lacks or a number out of range. */
|
|
3
|
+
export declare function valuesProblem(lesson: AnyLesson, values: Readonly<Record<string, LessonValue>>): string | undefined;
|
|
4
|
+
/** The values a beat state declares, by the state's id in any beat, or undefined when no beat declares it. */
|
|
5
|
+
export declare function stateValues(lesson: AnyLesson, state: string): Readonly<Record<string, LessonValue>> | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ReferenceItem } from './outline-types.ts';
|
|
3
|
+
export type AsideProps = {
|
|
4
|
+
readonly children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
/** A note beside the text: in the margin on wide screens, an indented block between paragraphs on narrow ones. */
|
|
7
|
+
export declare function Aside({ children }: AsideProps): ReactNode;
|
|
8
|
+
export type FootnoteProps = {
|
|
9
|
+
/** The note's id, unique in the article. Its number comes from reading order. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** The note, collected at the end of the article. */
|
|
12
|
+
readonly children: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/** A numbered note: a small number in the sentence that links to the note at the end, and back. */
|
|
15
|
+
export declare function Footnote({ id }: FootnoteProps): ReactNode;
|
|
16
|
+
export type ArticleNotesProps = {
|
|
17
|
+
/** Only the notes of this beat, small, for its slide in the present view. Every note when left out. */
|
|
18
|
+
readonly beat?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
/** The notes of an article, in reading order, each linked back to its place in the text. Numbers stay article-wide. */
|
|
21
|
+
export declare function ArticleNotes({ beat }: ArticleNotesProps): ReactNode;
|
|
22
|
+
export type CiteProps = {
|
|
23
|
+
/** The id of an item in the article's `References`. */
|
|
24
|
+
readonly id: string;
|
|
25
|
+
};
|
|
26
|
+
/** A citation in the text: the work's number in the references, linked to it. An unknown id shows an inline error. */
|
|
27
|
+
export declare function Cite({ id }: CiteProps): ReactNode;
|
|
28
|
+
export type ReferencesProps = {
|
|
29
|
+
/** The works the article cites, in the order they are numbered. */
|
|
30
|
+
readonly items: ReadonlyArray<ReferenceItem>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The numbered list of works the article cites. `Cite` links to each by its id; the present view shows it on the last
|
|
34
|
+
* beat.
|
|
35
|
+
*/
|
|
36
|
+
export declare function References({ items }: ReferencesProps): ReactNode;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LessonValue } from '../lesson/define-lesson.ts';
|
|
3
|
+
/** A work the article cites. Plain data, so an agent can write and check the list. */
|
|
4
|
+
export type ReferenceItem = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly authors: ReadonlyArray<string>;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly year: number;
|
|
9
|
+
readonly venue?: string | undefined;
|
|
10
|
+
readonly url?: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** A prediction of the article as its markup declares it. */
|
|
13
|
+
export type OutlinePrediction = {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly beat: string | null;
|
|
16
|
+
/** The lesson value the answer is read from, which stays out of an agent's view until the reader commits. */
|
|
17
|
+
readonly answerFrom?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** A figure of the article as its markup declares it. */
|
|
20
|
+
export type OutlineFigure = {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly beat: string | null;
|
|
23
|
+
readonly hasDescription: boolean;
|
|
24
|
+
/** How wide the essay draws it: the text column, or the text and its margin. A scrolly's figure is `text`. */
|
|
25
|
+
readonly size: 'text' | 'wide';
|
|
26
|
+
/** The figure itself, for a beat sheet's cells. */
|
|
27
|
+
readonly node: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
/** A step of a `Scrolly` as its markup declares it: the values or the state it shows. */
|
|
30
|
+
export type OutlineScrollyStep = {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly values?: Readonly<Record<string, LessonValue>> | undefined;
|
|
33
|
+
readonly state?: string | undefined;
|
|
34
|
+
};
|
|
35
|
+
/** A footnote of the article, with its beat, so the present view can show it on that beat's slide. */
|
|
36
|
+
export type OutlineFootnote = {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly beat: string | null;
|
|
39
|
+
readonly content: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
/** A beat of the article as its markup declares it. */
|
|
42
|
+
export type OutlineBeat = {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly figures: ReadonlyArray<OutlineFigure>;
|
|
45
|
+
/** The lesson names the beat's figures read: their `reads` and every name a lesson part inside them takes. */
|
|
46
|
+
readonly figureNames: ReadonlyArray<string>;
|
|
47
|
+
/** The params a `Param` in the beat's prose sets. */
|
|
48
|
+
readonly proseParams: ReadonlyArray<string>;
|
|
49
|
+
/** The steps of the beat's scrollies, in reading order. The present view walks them before its reveal steps. */
|
|
50
|
+
readonly scrollySteps: ReadonlyArray<OutlineScrollyStep>;
|
|
51
|
+
};
|
|
52
|
+
/** What an article's markup holds, found by reading it before it renders, so numbers agree on server and browser. */
|
|
53
|
+
export type ArticleOutline = {
|
|
54
|
+
readonly beats: ReadonlyArray<OutlineBeat>;
|
|
55
|
+
/** Every figure id, in reading order. Figures are numbered by it. */
|
|
56
|
+
readonly figures: ReadonlyArray<string>;
|
|
57
|
+
readonly footnotes: ReadonlyArray<OutlineFootnote>;
|
|
58
|
+
readonly references: ReadonlyArray<ReferenceItem>;
|
|
59
|
+
/** The param each `Playback` drives, with its beat. */
|
|
60
|
+
readonly playbacks: ReadonlyArray<{
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly beat: string | null;
|
|
63
|
+
}>;
|
|
64
|
+
/** The param each `Transport` controls. */
|
|
65
|
+
readonly transports: ReadonlyArray<string>;
|
|
66
|
+
/** Each `Predict`, with its beat and the lesson value its answer comes from, when it names one. */
|
|
67
|
+
readonly predictions: ReadonlyArray<OutlinePrediction>;
|
|
68
|
+
/** Each `Challenge`, with its beat. */
|
|
69
|
+
readonly challenges: ReadonlyArray<{
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly beat: string | null;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ValueFormat } from '../../../charts/src/index.ts';
|
|
3
|
+
/** The words of a prediction. Its result shows `youGuessed` and the guess, `answerIs` and the answer, and a verdict. */
|
|
4
|
+
export type PredictLabels = {
|
|
5
|
+
readonly kicker: string;
|
|
6
|
+
readonly yourGuess: string;
|
|
7
|
+
readonly commit: string;
|
|
8
|
+
readonly youGuessed: string;
|
|
9
|
+
readonly answerIs: string;
|
|
10
|
+
readonly right: string;
|
|
11
|
+
readonly wrong: string;
|
|
12
|
+
readonly showAnswer: string;
|
|
13
|
+
readonly range: string;
|
|
14
|
+
/** What an agent is told when it tries to commit for the reader. */
|
|
15
|
+
readonly needsReader: string;
|
|
16
|
+
};
|
|
17
|
+
type PredictOption = {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
};
|
|
21
|
+
/** A guess among options, one of which is right. */
|
|
22
|
+
export type ChoicePrediction = {
|
|
23
|
+
readonly options: ReadonlyArray<PredictOption>;
|
|
24
|
+
/** The id of the right option. */
|
|
25
|
+
readonly answer: string;
|
|
26
|
+
};
|
|
27
|
+
/** A guessed number. The answer is a fixed number or a lesson value read when the reader commits. */
|
|
28
|
+
export type NumberPrediction = {
|
|
29
|
+
readonly min: number;
|
|
30
|
+
readonly max: number;
|
|
31
|
+
readonly step: number;
|
|
32
|
+
readonly format: ValueFormat;
|
|
33
|
+
/** How far a guess may be from the answer and still be right. Defaults to one step. */
|
|
34
|
+
readonly tolerance?: number | undefined;
|
|
35
|
+
} & ({
|
|
36
|
+
readonly answer: number;
|
|
37
|
+
readonly answerFrom?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
/** A number param or derived value of the lesson whose value, when the reader commits, is the answer. */
|
|
40
|
+
readonly answerFrom: string;
|
|
41
|
+
readonly answer?: undefined;
|
|
42
|
+
});
|
|
43
|
+
export type PredictProps = {
|
|
44
|
+
/** The prediction's id, unique in the article. The reader's progress records the guess under it. */
|
|
45
|
+
readonly id: string;
|
|
46
|
+
/** The question, such as "At temperature 4, how much entropy is left?". */
|
|
47
|
+
readonly prompt: ReactNode;
|
|
48
|
+
/** The explanation, shown once the reader commits. Agents do not see it before then. */
|
|
49
|
+
readonly children: ReactNode;
|
|
50
|
+
readonly labels?: Partial<PredictLabels> | undefined;
|
|
51
|
+
} & (ChoicePrediction | NumberPrediction);
|
|
52
|
+
/**
|
|
53
|
+
* Asks the reader to commit a guess before the answer shows: one of a few options, or a number on a slider. Once the
|
|
54
|
+
* reader commits, the answer and the explanation appear and the reader's progress keeps the guess. An agent can read
|
|
55
|
+
* the question but never commits for the reader, and does not see the answer before the reader commits.
|
|
56
|
+
*/
|
|
57
|
+
export declare function Predict(props: PredictProps): ReactNode;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ChangeDetails, ChangeSource } from '@ui-sdk/core';
|
|
2
|
+
import type { PartProps } from '@ui-sdk/react/primitive';
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
/** A prediction the reader committed: their guess, the answer at that moment, and whether the guess was right. */
|
|
5
|
+
export type PredictionRecord = {
|
|
6
|
+
readonly value: number | string;
|
|
7
|
+
readonly answer: number | string;
|
|
8
|
+
readonly isCorrect: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* What the reader has done in one article. Only the reader's own acts count: an agent's change never commits a
|
|
12
|
+
* prediction, reaches a challenge or shows a hint.
|
|
13
|
+
*/
|
|
14
|
+
export type LessonProgress = {
|
|
15
|
+
/** Each committed prediction, by the `Predict` id. */
|
|
16
|
+
readonly predictions: Readonly<Record<string, PredictionRecord>>;
|
|
17
|
+
/** The ids of the challenges the reader reached, in the order reached. */
|
|
18
|
+
readonly reached: ReadonlyArray<string>;
|
|
19
|
+
/** How many hints the reader asked for, by the `Challenge` id. */
|
|
20
|
+
readonly hints: Readonly<Record<string, number>>;
|
|
21
|
+
/** The ids of the beats the reader has been on, in the order first visited. */
|
|
22
|
+
readonly visited: ReadonlyArray<string>;
|
|
23
|
+
};
|
|
24
|
+
/** Why the progress changed: a commit, a challenge reached, a hint asked for, a beat visited, a restore or a reset. */
|
|
25
|
+
export type ProgressChangeReason = 'commit' | 'reach' | 'hint-press' | 'visit' | 'restore' | 'reset';
|
|
26
|
+
/** What a progress change reports: its reason, event and source, and `cancel()` to refuse it. */
|
|
27
|
+
export type ProgressChangeDetails = ChangeDetails<ProgressChangeReason>;
|
|
28
|
+
/** What a progress change says about itself. */
|
|
29
|
+
export type ProgressOrigin = {
|
|
30
|
+
readonly reason: ProgressChangeReason;
|
|
31
|
+
readonly event?: Event | undefined;
|
|
32
|
+
readonly source?: ChangeSource | undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare const emptyProgress: {
|
|
35
|
+
readonly predictions: {};
|
|
36
|
+
readonly reached: readonly [];
|
|
37
|
+
readonly hints: {};
|
|
38
|
+
readonly visited: readonly [];
|
|
39
|
+
};
|
|
40
|
+
/** Where the reader's progress lives: controlled, kept by the article, or saved under a storage key as well. */
|
|
41
|
+
export type ProgressOptions = {
|
|
42
|
+
readonly progress?: LessonProgress | undefined;
|
|
43
|
+
readonly defaultProgress?: LessonProgress | undefined;
|
|
44
|
+
readonly onProgressChange?: ((progress: LessonProgress, details: ProgressChangeDetails) => void) | undefined;
|
|
45
|
+
readonly storageKey?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
/** The calls the progress primitive offers the parts of an article. Each returns whether the progress changed. */
|
|
48
|
+
export type ProgressApi = {
|
|
49
|
+
/** Records the reader's committed prediction. A prediction commits once. */
|
|
50
|
+
readonly commit: (id: string, record: PredictionRecord, origin: ProgressOrigin) => boolean;
|
|
51
|
+
/** Records that the reader reached a challenge. */
|
|
52
|
+
readonly reach: (id: string, origin: ProgressOrigin) => boolean;
|
|
53
|
+
/** Shows one more hint of a challenge. */
|
|
54
|
+
readonly showHint: (id: string, origin: ProgressOrigin) => boolean;
|
|
55
|
+
/** Records that the reader is on a beat. */
|
|
56
|
+
readonly visit: (beat: string, origin: ProgressOrigin) => boolean;
|
|
57
|
+
/** Forgets every prediction, challenge, hint and visit. */
|
|
58
|
+
readonly reset: (origin?: ProgressOrigin) => boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Renders an article element as the root of `lesson-progress`, with props built from the progress and its calls. A
|
|
62
|
+
* change an agent makes is refused before `onProgressChange` hears of it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useProgressRoot(options: ProgressOptions, props: (progress: LessonProgress, api: ProgressApi) => PartProps<'article'>): ReactElement | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LessonValue } from '../lesson/define-lesson.ts';
|
|
3
|
+
export type ScrollyStepProps = {
|
|
4
|
+
/** The step's id, unique in its scrolly. */
|
|
5
|
+
readonly id: string;
|
|
6
|
+
/** The values this step applies while it is in view. */
|
|
7
|
+
readonly values?: Readonly<Record<string, LessonValue>> | undefined;
|
|
8
|
+
/** A state of a lesson beat this step shows while it is in view, by its id. */
|
|
9
|
+
readonly state?: string | undefined;
|
|
10
|
+
/** The step's prose. */
|
|
11
|
+
readonly children: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/** One step of a `Scrolly`: prose that sets the lesson's values while the reader has it in view. */
|
|
14
|
+
export declare function ScrollyStep({ children }: ScrollyStepProps): ReactNode;
|
|
15
|
+
export type ScrollyProps = {
|
|
16
|
+
/** The figure that stays in view beside the steps and follows the values each step applies. */
|
|
17
|
+
readonly figure: ReactNode;
|
|
18
|
+
/** The steps, as `ScrollyStep` elements. */
|
|
19
|
+
readonly children: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A figure that stays in view while the reader scrolls through steps of prose beside it, each setting the lesson's
|
|
23
|
+
* values. The present view lists the steps beside the figure and walks them as the beat's first steps. The static view
|
|
24
|
+
* prints each step with the figure at its values.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Scrolly({ figure, children }: ScrollyProps): ReactNode;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
/** What assistive technology hears after a term or a diagram part's name. */
|
|
3
|
+
export type TermLabels = {
|
|
4
|
+
readonly hint: string;
|
|
5
|
+
};
|
|
2
6
|
export type TermProps = {
|
|
3
7
|
/** The record the term names, by the id the figures use for it: a series, a run, a step. */
|
|
4
8
|
readonly inspects: string;
|
|
5
9
|
/** The words in the sentence. */
|
|
6
10
|
readonly children: ReactNode;
|
|
11
|
+
readonly labels?: Partial<TermLabels> | undefined;
|
|
7
12
|
};
|
|
8
13
|
/**
|
|
9
14
|
* A word in prose that points into the figures: hovering or focusing "the base run" highlights that run in every chart
|
|
10
15
|
* of the enclosing `ChartLink`. A press does the same on touch. Its dotted underline takes the record's hue when a
|
|
11
16
|
* `ToneScope` names it, so the sentence doubles as a legend.
|
|
12
17
|
*/
|
|
13
|
-
export declare function Term({ inspects, children }: TermProps): ReactNode;
|
|
18
|
+
export declare function Term({ inspects, children, labels }: TermProps): ReactNode;
|
|
14
19
|
export type DiagramPartProps = {
|
|
15
20
|
/** The record this part of the diagram stands for, by the id the figures and terms use for it. */
|
|
16
21
|
readonly inspects: string;
|
|
@@ -21,9 +26,10 @@ export type DiagramPartProps = {
|
|
|
21
26
|
* emphasis while the link inspects this record.
|
|
22
27
|
*/
|
|
23
28
|
readonly children: ReactNode;
|
|
29
|
+
readonly labels?: Partial<TermLabels> | undefined;
|
|
24
30
|
};
|
|
25
31
|
/**
|
|
26
32
|
* A part of a hand-drawn SVG diagram linked to the figures both ways: pointing at it or focusing it highlights its
|
|
27
33
|
* record in every chart of the enclosing `ChartLink`. It is emphasized whenever a chart or a `Term` inspects it.
|
|
28
34
|
*/
|
|
29
|
-
export declare function DiagramPart({ inspects, label, children }: DiagramPartProps): ReactNode;
|
|
35
|
+
export declare function DiagramPart({ inspects, label, children, labels }: DiagramPartProps): ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type TeXProps = {
|
|
3
|
+
/** The TeX source, such as `p_i = e^{z_i / T} / \sum_j e^{z_j / T}`. */
|
|
4
|
+
readonly children: string;
|
|
5
|
+
/** A block of its own, centred between paragraphs. Inline in the sentence by default. */
|
|
6
|
+
readonly isDisplay?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Mathematics in TeX. The article's `math` function typesets it; without one the TeX source shows in the monospace
|
|
10
|
+
* face. Assistive technology always reads the source, so the formula means the same with or without a typesetter.
|
|
11
|
+
*/
|
|
12
|
+
export declare function TeX({ children, isDisplay }: TeXProps): ReactNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ArticleScope } from './article-context.ts';
|
|
3
|
+
export type ViewProps = {
|
|
4
|
+
readonly article: ArticleScope;
|
|
5
|
+
/** The title, byline and summary. */
|
|
6
|
+
readonly header: ReactNode;
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The article view: a scrolling essay with a contents list that follows the reading position. Scrolling a beat into the
|
|
11
|
+
* reading band makes it the lesson's beat, and a beat set elsewhere, such as by an agent, scrolls into view.
|
|
12
|
+
*/
|
|
13
|
+
export declare function EssayView({ article, header, children }: ViewProps): ReactNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ViewProps } from './view-essay.tsx';
|
|
3
|
+
/**
|
|
4
|
+
* The present view: one beat per slide, with its notes, walked by Right, Space and Left through scrolly steps, reveal
|
|
5
|
+
* steps and beats. Moving to a beat shows its first declared state, coming back included; a scrolly step lays its
|
|
6
|
+
* values over that state, so on entry its first step wins. Keys inside a control, such as a slider, stay with it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function PresentView({ article, children }: ViewProps): ReactNode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ViewProps } from './view-essay.tsx';
|
|
3
|
+
/**
|
|
4
|
+
* The sheet view, for authors, reviewers and agents: every beat at each of its declared states, small and read-only,
|
|
5
|
+
* with its tutor notes, then a list of checks. Each cell holds its own read-only lesson.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SheetView({ article }: ViewProps): ReactNode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ViewProps } from './view-essay.tsx';
|
|
3
|
+
/**
|
|
4
|
+
* The static view: every beat open at its first state, every reveal shown, each figure followed by its description, and
|
|
5
|
+
* nothing that needs a script to be read. Feed readers, printers and readers without JavaScript get this view.
|
|
6
|
+
*/
|
|
7
|
+
export declare function StaticView({ article, header, children }: ViewProps): ReactNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/** An element found in an article's markup, with its props as plain values to read. */
|
|
3
|
+
export type MarkupElement = ReactElement<Readonly<Record<string, unknown>>>;
|
|
4
|
+
/** Where an element sits: the beat and the figure around it, when there are any. */
|
|
5
|
+
export type MarkupPlace = {
|
|
6
|
+
readonly beat: string | null;
|
|
7
|
+
readonly figure: string | null;
|
|
8
|
+
};
|
|
9
|
+
/** One element of the markup and its place. */
|
|
10
|
+
export type MarkupEntry = {
|
|
11
|
+
readonly element: MarkupElement;
|
|
12
|
+
readonly place: MarkupPlace;
|
|
13
|
+
};
|
|
14
|
+
/** Decides the place of an element's props from the element and the place around it. */
|
|
15
|
+
export type PlaceOf = (input: {
|
|
16
|
+
readonly element: MarkupElement;
|
|
17
|
+
readonly place: MarkupPlace;
|
|
18
|
+
readonly prop: string;
|
|
19
|
+
}) => MarkupPlace;
|
|
20
|
+
/** What `walkMarkup` walks: the markup, the place it starts in, and how an element's props find their place. */
|
|
21
|
+
export type MarkupWalk = {
|
|
22
|
+
readonly node: unknown;
|
|
23
|
+
readonly place: MarkupPlace;
|
|
24
|
+
readonly placeOf: PlaceOf;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Walks markup the author wrote, in reading order, through children and every prop that holds elements, such as a
|
|
28
|
+
* caption or a scrolly's figure. Components the author defined are not rendered, so their own output is not seen.
|
|
29
|
+
*
|
|
30
|
+
* @yields Each element with the beat and the figure around it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function walkMarkup({ node, place, placeOf }: MarkupWalk): Generator<MarkupEntry>;
|
|
33
|
+
/** The text a prop holds, or undefined when it holds something else. */
|
|
34
|
+
export declare function textProp(element: MarkupElement, prop: string): string | undefined;
|