@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,85 @@
|
|
|
1
|
+
import type { AnyLesson, LessonValue, ToggleValue } from '../lesson/define-lesson.ts';
|
|
2
|
+
/** A number format as plain JSON: the `Intl` options, or null for a format the author wrote as a function. */
|
|
3
|
+
export type OutlineFormat = Readonly<Intl.NumberFormatOptions> | null;
|
|
4
|
+
/** A param in an outline: its name, kind, label and opening value, with its range or options. */
|
|
5
|
+
export type OutlineParam = {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly kind: 'number';
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly value: number;
|
|
10
|
+
readonly min: number;
|
|
11
|
+
readonly max: number;
|
|
12
|
+
readonly step: number;
|
|
13
|
+
readonly scale: 'linear' | 'log';
|
|
14
|
+
readonly format: OutlineFormat;
|
|
15
|
+
} | {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly kind: 'choice';
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly value: string;
|
|
20
|
+
readonly options: ReadonlyArray<{
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly label: string;
|
|
23
|
+
}>;
|
|
24
|
+
} | {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly kind: 'toggle';
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly value: ToggleValue;
|
|
29
|
+
};
|
|
30
|
+
/** A derived value in an outline, with the names it reads. */
|
|
31
|
+
export type OutlineDerived = {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly label: string;
|
|
34
|
+
readonly format: OutlineFormat;
|
|
35
|
+
readonly reads: ReadonlyArray<string>;
|
|
36
|
+
};
|
|
37
|
+
/** A declared state with the derived values it leads to. */
|
|
38
|
+
export type OutlineState = {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
/** The params the state sets. */
|
|
42
|
+
readonly values: Readonly<Record<string, LessonValue>>;
|
|
43
|
+
/** Every derived value once the state is shown over the opening values. */
|
|
44
|
+
readonly derived: Readonly<Record<string, number>>;
|
|
45
|
+
};
|
|
46
|
+
/** A beat in an outline, with its tutor notes. */
|
|
47
|
+
export type OutlineBeat = {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly title: string;
|
|
50
|
+
readonly goal: string | null;
|
|
51
|
+
readonly misconception: string | null;
|
|
52
|
+
readonly hints: ReadonlyArray<string>;
|
|
53
|
+
readonly steps: number;
|
|
54
|
+
readonly states: ReadonlyArray<OutlineState>;
|
|
55
|
+
};
|
|
56
|
+
/** A defined lesson as plain JSON: what an agent reads to know the lesson without rendering it. */
|
|
57
|
+
export type LessonOutline = {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly title: string;
|
|
60
|
+
readonly params: ReadonlyArray<OutlineParam>;
|
|
61
|
+
readonly derived: ReadonlyArray<OutlineDerived>;
|
|
62
|
+
/** Every param and derived value at the opening. */
|
|
63
|
+
readonly initial: Readonly<Record<string, LessonValue>>;
|
|
64
|
+
readonly beats: ReadonlyArray<OutlineBeat>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The outline of a defined lesson as plain JSON: params with their ranges, derived values with what they read, and
|
|
68
|
+
* beats with tutor notes and each state's derived values. A tutor or a planning agent reads it instead of the page.
|
|
69
|
+
*/
|
|
70
|
+
export declare function describeLesson(lesson: AnyLesson): LessonOutline;
|
|
71
|
+
/**
|
|
72
|
+
* A param or derived value written as the reader sees it: a number in its declared format, a choice by its option's
|
|
73
|
+
* label, a toggle as on or off.
|
|
74
|
+
*/
|
|
75
|
+
export declare function writtenValue({ lesson, name, value, locale, }: {
|
|
76
|
+
readonly lesson: AnyLesson;
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly value: LessonValue;
|
|
79
|
+
readonly locale: string;
|
|
80
|
+
}): string;
|
|
81
|
+
/**
|
|
82
|
+
* The lesson as text an agent reads without rendering it. It lists the params and derived values, then each beat with
|
|
83
|
+
* its tutor notes. Each declared state follows, with every value written in its format.
|
|
84
|
+
*/
|
|
85
|
+
export declare function lessonWalk(lesson: AnyLesson, locale: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Every teaching part an author or an agent chooses between when writing an explainer, in reading order. */
|
|
2
|
+
export declare const explainerParts: readonly ['Lesson', 'Param', 'Value', 'ParamSlider', 'ParamChoice', 'ParamToggle', 'Playback', 'Transport', 'Scene', 'SceneNode', 'SceneWire', 'SceneGroup', 'SceneBracket', 'SceneCallout', 'SceneHighlight', 'SceneCustom', 'SceneAxes', 'SceneCurve', 'ScenePoint', 'SceneVector', 'SceneProjection', 'SceneRegion', 'SceneRule', 'SceneCard', 'SceneStack', 'SceneSlot', 'SceneCells', 'SceneToken', 'SceneTokens', 'SceneFlow', 'LessonFlow', 'MorphScope', 'Article', 'Beat', 'Figure', 'FigureReference', 'Reveal', 'Scrolly', 'Predict', 'Challenge', 'Aside', 'Footnote', 'Cite', 'References', 'TeX', 'Term', 'DiagramPart'];
|
|
3
|
+
/** The name of a teaching part. */
|
|
4
|
+
export type ExplainerPart = (typeof explainerParts)[number];
|
|
5
|
+
/** One teaching part in the guide: the reader question it answers, when to use it, and a few lines of TSX. */
|
|
6
|
+
export type ExplainerGuideEntry = {
|
|
7
|
+
readonly part: ExplainerPart;
|
|
8
|
+
/** The public entry to import it from. */
|
|
9
|
+
readonly entry: string;
|
|
10
|
+
/** The question a reader has that this part answers, in the reader's words. */
|
|
11
|
+
readonly question: string;
|
|
12
|
+
/** When to use it, and when another part is better, naming it. */
|
|
13
|
+
readonly guidance: string;
|
|
14
|
+
/** A few lines of TSX that use it well. */
|
|
15
|
+
readonly example: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The teaching parts, each with the reader question it answers, when to use it, and a short TSX example. Read it to
|
|
19
|
+
* choose parts when planning a lesson; a plan's figure names one of these parts or a chart from `chartGuide`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const explainerGuide: ReadonlyArray<ExplainerGuideEntry>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AnyLesson } from '../lesson/define-lesson.ts';
|
|
2
|
+
/** One thing a check found: where it is, a sentence that says what to do, and whether it stops the lesson. */
|
|
3
|
+
export type LessonFinding = {
|
|
4
|
+
/** Where the finding is, written like `beats[2].states[0].values.temperature`. */
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
/** `error` means `defineLesson` would refuse it; `advice` is teaching practice the author may decline. */
|
|
8
|
+
readonly severity: 'error' | 'advice';
|
|
9
|
+
};
|
|
10
|
+
/** What a value must be to suit a param: a number in a range, one option id, or true or false. */
|
|
11
|
+
export type ValueRule = {
|
|
12
|
+
readonly kind: 'number';
|
|
13
|
+
readonly min: number;
|
|
14
|
+
readonly max: number;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'choice';
|
|
17
|
+
readonly ids: ReadonlyArray<string>;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'toggle';
|
|
20
|
+
};
|
|
21
|
+
/** An error finding. */
|
|
22
|
+
export declare function errorAt(path: string, message: string): LessonFinding;
|
|
23
|
+
/** An advice finding. */
|
|
24
|
+
export declare function adviceAt(path: string, message: string): LessonFinding;
|
|
25
|
+
/** The fields of a plain object, or undefined for anything else. */
|
|
26
|
+
export declare function fieldsOf(value: unknown): ReadonlyMap<string, unknown> | undefined;
|
|
27
|
+
/** A value's JSON kind with its article, for messages: "a string", "an array", "nothing". */
|
|
28
|
+
export declare function kindText(value: unknown): string;
|
|
29
|
+
/** Why `value` does not suit a param with this rule, or undefined when it does. */
|
|
30
|
+
export declare function ruleProblem(name: string, rule: ValueRule, value: unknown): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Why a lesson would refuse `value` for the param `name`, or undefined when it takes it. Ask before setting a value
|
|
33
|
+
* through the agent bridge, or when checking a tour or a state written by hand.
|
|
34
|
+
*/
|
|
35
|
+
export declare function valueProblem({ lesson, name, value, }: {
|
|
36
|
+
readonly lesson: AnyLesson;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly value: unknown;
|
|
39
|
+
}): string | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lessons as plain data, for authors and their agents. Check a plan before writing components, read a defined lesson as
|
|
3
|
+
* an outline or as text, get teaching advice, and choose parts from the guide. Runs in Node and in the browser.
|
|
4
|
+
*/
|
|
5
|
+
export { checkLesson } from './advice.ts';
|
|
6
|
+
export type { LessonOutline, OutlineBeat, OutlineDerived, OutlineFormat, OutlineParam, OutlineState, } from './describe-lesson.ts';
|
|
7
|
+
export { describeLesson, lessonWalk, writtenValue } from './describe-lesson.ts';
|
|
8
|
+
export type { ExplainerGuideEntry, ExplainerPart } from './explainer-guide.ts';
|
|
9
|
+
export { explainerGuide, explainerParts } from './explainer-guide.ts';
|
|
10
|
+
export type { LessonFinding } from './findings.ts';
|
|
11
|
+
export { valueProblem } from './findings.ts';
|
|
12
|
+
export type { LessonPlan, LessonPlanAsk, LessonPlanBeat, LessonPlanDerived, LessonPlanFigure } from './lesson-plan.ts';
|
|
13
|
+
export type { LessonPlanResult } from './validate-plan.ts';
|
|
14
|
+
export { validateLessonPlan } from './validate-plan.ts';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ValueFormat } from '../../../charts/src/index.ts';
|
|
2
|
+
import type { LessonBeat, LessonParam } from '../lesson/define-lesson.ts';
|
|
3
|
+
/** A derived value as a plan names it: what it reads and its formula in words, before any code exists. */
|
|
4
|
+
export type LessonPlanDerived = {
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly format: ValueFormat;
|
|
7
|
+
/** The params and earlier derived values it reads. */
|
|
8
|
+
readonly reads: ReadonlyArray<string>;
|
|
9
|
+
/** The formula in words, such as "the softmax share of the followed token". */
|
|
10
|
+
readonly formula: string;
|
|
11
|
+
};
|
|
12
|
+
/** The figure a beat shows: a teaching part from `explainerGuide` or a chart name, and the question it answers. */
|
|
13
|
+
export type LessonPlanFigure = {
|
|
14
|
+
readonly part: string;
|
|
15
|
+
readonly question: string;
|
|
16
|
+
/** The params and derived values it draws. */
|
|
17
|
+
readonly shows?: ReadonlyArray<string> | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** A prediction the reader commits to, or a challenge the reader reaches by moving params. */
|
|
20
|
+
export type LessonPlanAsk = {
|
|
21
|
+
readonly kind: 'predict' | 'challenge';
|
|
22
|
+
readonly prompt: string;
|
|
23
|
+
};
|
|
24
|
+
/** One beat as a plan describes it: the lesson beat, with the figure it shows and what it asks. */
|
|
25
|
+
export type LessonPlanBeat = LessonBeat & {
|
|
26
|
+
readonly figure?: LessonPlanFigure | undefined;
|
|
27
|
+
readonly ask?: LessonPlanAsk | undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The plain JSON an agent drafts before writing any component: who it is for, the one idea, the values and the beats.
|
|
31
|
+
* `validateLessonPlan` checks it. Its params and beats carry over to `defineLesson` unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export type LessonPlan = {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly title: string;
|
|
36
|
+
/** Who reads it and what they already know. */
|
|
37
|
+
readonly audience: string;
|
|
38
|
+
/** The one idea the reader should leave with. */
|
|
39
|
+
readonly idea: string;
|
|
40
|
+
readonly params: Readonly<Record<string, LessonParam>>;
|
|
41
|
+
readonly derived?: Readonly<Record<string, LessonPlanDerived>> | undefined;
|
|
42
|
+
readonly beats: ReadonlyArray<LessonPlanBeat>;
|
|
43
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LessonFinding } from './findings.ts';
|
|
2
|
+
/** What checking a lesson plan found. The plan is valid when no finding is an error; advice never blocks it. */
|
|
3
|
+
export type LessonPlanResult = {
|
|
4
|
+
readonly isValid: boolean;
|
|
5
|
+
readonly findings: ReadonlyArray<LessonFinding>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Checks a lesson plan an agent drafted, before any component is written. Errors are shapes and names `defineLesson`
|
|
9
|
+
* would refuse; advice is teaching practice. Every finding has a path and a sentence that says what to do.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateLessonPlan(input: unknown): LessonPlanResult;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `listener` once per animation frame while subscribed. One loop serves every subscriber, so everything that
|
|
3
|
+
* moves on a page moves in step.
|
|
4
|
+
*/
|
|
5
|
+
export declare const onFrame: (listener: (now: number) => void) => () => void;
|
|
6
|
+
/** Whether the reader asked for reduced motion. False where there is no window. */
|
|
7
|
+
export declare function isMotionReduced(): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** How long a move takes. `instant` jumps, and so does every pace when the reader asked for reduced motion. */
|
|
2
|
+
export type Pace = 'instant' | 'fast' | 'regular' | 'slow';
|
|
3
|
+
/** A set of named numbers that eases toward a target on the shared clock. */
|
|
4
|
+
export type Tween<Key extends string> = {
|
|
5
|
+
/** The values on screen now. The same object is returned until a frame changes them. */
|
|
6
|
+
readonly get: () => Readonly<Record<Key, number>>;
|
|
7
|
+
/** Moves to `target` from the values on screen, so a new target in the middle of a move is smooth. */
|
|
8
|
+
readonly to: (target: Readonly<Record<Key, number>>, pace?: Pace) => void;
|
|
9
|
+
/** Jumps to `target` without animating. */
|
|
10
|
+
readonly jump: (target: Readonly<Record<Key, number>>) => void;
|
|
11
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
12
|
+
/** Stops any move in flight. The tween still answers `get` and can be moved again. */
|
|
13
|
+
readonly destroy: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Makes a tween that starts at `initial`. Give it a new target with `to` and read `get` on each change: authors
|
|
17
|
+
* describe where things are, and the tween supplies the motion between.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTween<Key extends string>(initial: Readonly<Record<Key, number>>): Tween<Key>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Pace } from './tween.ts';
|
|
2
|
+
/**
|
|
3
|
+
* An animated copy of `target`. The first render shows `target`, and each later change eases to the new values on the
|
|
4
|
+
* shared clock, starting from whatever is on screen.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useTween<Key extends string>(target: Readonly<Record<Key, number>>, pace?: Pace): Readonly<Record<Key, number>>;
|