@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,69 @@
|
|
|
1
|
+
import type { NumericDomain } from '../../../../charts/src/index.ts';
|
|
2
|
+
import type { HeatmapPalette } from '../../../../charts/src/matrix/index.ts';
|
|
3
|
+
import type { SceneOffset } from '../scene-geometry.ts';
|
|
4
|
+
/** The pixel boxes of the named cell sizes. */
|
|
5
|
+
export declare const sceneCellSizes: {
|
|
6
|
+
readonly small: {
|
|
7
|
+
readonly width: 40;
|
|
8
|
+
readonly height: 28;
|
|
9
|
+
};
|
|
10
|
+
readonly medium: {
|
|
11
|
+
readonly width: 56;
|
|
12
|
+
readonly height: 36;
|
|
13
|
+
};
|
|
14
|
+
readonly large: {
|
|
15
|
+
readonly width: 76;
|
|
16
|
+
readonly height: 46;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/** A named cell size. */
|
|
20
|
+
export type SceneCellSizeName = keyof typeof sceneCellSizes;
|
|
21
|
+
/** The pixels between neighbouring cells. */
|
|
22
|
+
export declare const cellGap = 2;
|
|
23
|
+
/** One cell as the author describes it. */
|
|
24
|
+
export type SceneCellInput = {
|
|
25
|
+
/** Overrides the cell's id, `${grid id}.${row}.${column}`, for a cell whose identity must survive a reorder. */
|
|
26
|
+
readonly id?: string | undefined;
|
|
27
|
+
/** What the cell shows instead of its formatted value, such as a word or a symbol. */
|
|
28
|
+
readonly text?: string | undefined;
|
|
29
|
+
/** The cell's number. It eases when it changes, and it sets the cell's color. */
|
|
30
|
+
readonly value?: number | undefined;
|
|
31
|
+
/** The readout sentence. Left out, the cell says its row, column and value. */
|
|
32
|
+
readonly label?: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
/** The numbers of a vector or a matrix: a flat list, or a list of rows. */
|
|
35
|
+
export type SceneCellValues = ReadonlyArray<number | ReadonlyArray<number>>;
|
|
36
|
+
/** Which way a flat list of values runs. */
|
|
37
|
+
export type SceneCellsDirection = 'row' | 'column';
|
|
38
|
+
/** The grid of cells an author described: rows of cells. A flat list of values becomes one row, or one column. */
|
|
39
|
+
export declare function cellGrid({ values, cells, direction, }: {
|
|
40
|
+
readonly values: SceneCellValues | undefined;
|
|
41
|
+
readonly cells: ReadonlyArray<ReadonlyArray<SceneCellInput>> | undefined;
|
|
42
|
+
readonly direction: SceneCellsDirection;
|
|
43
|
+
}): ReadonlyArray<ReadonlyArray<SceneCellInput>>;
|
|
44
|
+
/** The pixel box of a grid of `rows` by `columns` cells. */
|
|
45
|
+
export declare function cellsExtent({ rows, columns, size, }: {
|
|
46
|
+
readonly rows: number;
|
|
47
|
+
readonly columns: number;
|
|
48
|
+
readonly size: SceneCellSizeName;
|
|
49
|
+
}): {
|
|
50
|
+
readonly width: number;
|
|
51
|
+
readonly height: number;
|
|
52
|
+
};
|
|
53
|
+
/** A cell's center as a shift in pixels from the grid's center: across to the right, then down. */
|
|
54
|
+
export declare function cellOffset({ row, column, rows, columns, size, }: {
|
|
55
|
+
readonly row: number;
|
|
56
|
+
readonly column: number;
|
|
57
|
+
readonly rows: number;
|
|
58
|
+
readonly columns: number;
|
|
59
|
+
readonly size: SceneCellSizeName;
|
|
60
|
+
}): SceneOffset;
|
|
61
|
+
/**
|
|
62
|
+
* The values the color scale spans: the one the author gave, or zero to the largest magnitude, or its mirror for a
|
|
63
|
+
* diverging palette.
|
|
64
|
+
*/
|
|
65
|
+
export declare function cellsDomain({ grid, palette, domain, }: {
|
|
66
|
+
readonly grid: ReadonlyArray<ReadonlyArray<SceneCellInput>>;
|
|
67
|
+
readonly palette: HeatmapPalette | undefined;
|
|
68
|
+
readonly domain: NumericDomain | undefined;
|
|
69
|
+
}): NumericDomain;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
|
|
4
|
+
import type { Pace } from '../../time/tween.ts';
|
|
5
|
+
import type { SceneOffset, ScenePosition } from '../scene-geometry.ts';
|
|
6
|
+
import type { SceneDelay } from '../scene-stagger.ts';
|
|
7
|
+
import type { SceneCardSizeName } from './stack-layout.ts';
|
|
8
|
+
/** The ranks of a playing card, lowest first with the ace first. */
|
|
9
|
+
export declare const cardRanks: readonly ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'];
|
|
10
|
+
/** A playing card's rank. */
|
|
11
|
+
export type CardRank = (typeof cardRanks)[number];
|
|
12
|
+
/** The four suits of a playing card. */
|
|
13
|
+
export declare const cardSuits: readonly ['heart', 'diamond', 'spade', 'club'];
|
|
14
|
+
/** A playing card's suit. */
|
|
15
|
+
export type CardSuit = (typeof cardSuits)[number];
|
|
16
|
+
/** The words a card speaks that are not the author's content. `{rank}`, `{suit}` and `{name}` are filled in. */
|
|
17
|
+
export type SceneCardLabels = {
|
|
18
|
+
readonly ranks: Readonly<Record<CardRank, string>>;
|
|
19
|
+
readonly suits: Readonly<Record<CardSuit, string>>;
|
|
20
|
+
/** The card's name for the readout, such as "Queen of Hearts". */
|
|
21
|
+
readonly name: string;
|
|
22
|
+
/** The readout of a face-down card. `{name}` is its name; the default leaves it out to keep the card secret. */
|
|
23
|
+
readonly faceDown: string;
|
|
24
|
+
/** `{id}` is the card that has no place. */
|
|
25
|
+
readonly noPlace: string;
|
|
26
|
+
};
|
|
27
|
+
/** The plain English words of a card. */
|
|
28
|
+
export declare const sceneCardLabels: {
|
|
29
|
+
readonly ranks: {
|
|
30
|
+
readonly A: 'Ace';
|
|
31
|
+
readonly '2': '2';
|
|
32
|
+
readonly '3': '3';
|
|
33
|
+
readonly '4': '4';
|
|
34
|
+
readonly '5': '5';
|
|
35
|
+
readonly '6': '6';
|
|
36
|
+
readonly '7': '7';
|
|
37
|
+
readonly '8': '8';
|
|
38
|
+
readonly '9': '9';
|
|
39
|
+
readonly '10': '10';
|
|
40
|
+
readonly J: 'Jack';
|
|
41
|
+
readonly Q: 'Queen';
|
|
42
|
+
readonly K: 'King';
|
|
43
|
+
};
|
|
44
|
+
readonly suits: {
|
|
45
|
+
readonly heart: 'Hearts';
|
|
46
|
+
readonly diamond: 'Diamonds';
|
|
47
|
+
readonly spade: 'Spades';
|
|
48
|
+
readonly club: 'Clubs';
|
|
49
|
+
};
|
|
50
|
+
readonly name: '{rank} of {suit}';
|
|
51
|
+
readonly faceDown: 'A card, face down';
|
|
52
|
+
readonly noPlace: 'The card "{id}" has no place. Give it `at`, or list it in a SceneStack declared before it.';
|
|
53
|
+
};
|
|
54
|
+
/** The tone a suit takes when neither the card nor the tone scope names one. */
|
|
55
|
+
export declare const suitTones: Readonly<Record<CardSuit, ChartTone>>;
|
|
56
|
+
export type SceneCardProps = {
|
|
57
|
+
/** Stable across states: the card with this id moves, turns and lifts to its new props. */
|
|
58
|
+
readonly id: string;
|
|
59
|
+
/** The card's center in data units. Left out, a `SceneStack` that lists the card places it. */
|
|
60
|
+
readonly at?: ScenePosition | undefined;
|
|
61
|
+
/** A shift from `at` in pixels, for hand placement. Ignored while a stack places the card. */
|
|
62
|
+
readonly offset?: SceneOffset | undefined;
|
|
63
|
+
/** Degrees of turn in the page, for hand placement. Ignored while a stack places the card. */
|
|
64
|
+
readonly rotate?: number | undefined;
|
|
65
|
+
/** With `suit`, a playing card: the corners and the center show them. */
|
|
66
|
+
readonly rank?: CardRank | undefined;
|
|
67
|
+
readonly suit?: CardSuit | undefined;
|
|
68
|
+
/** What a generic card shows in its center: a word, a symbol or a number. */
|
|
69
|
+
readonly text?: string | undefined;
|
|
70
|
+
/** The readout sentence. Left out, a playing card says its name, such as "Queen of Hearts". */
|
|
71
|
+
readonly label?: string | undefined;
|
|
72
|
+
/** False turns the card over, easing through a mid-turn. Defaults to true. */
|
|
73
|
+
readonly isFaceUp?: boolean | undefined;
|
|
74
|
+
/** 0 rests on the table, 1 is raised toward the reader. */
|
|
75
|
+
readonly lift?: number | undefined;
|
|
76
|
+
/** Degrees of lean around the horizontal axis. */
|
|
77
|
+
readonly tilt?: number | undefined;
|
|
78
|
+
/** The fixed pixel box in card proportions. A stack's size wins while it places the card. Defaults to `medium`. */
|
|
79
|
+
readonly size?: SceneCardSizeName | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* The hue that names the card. Left out: the tone scope's tone for the card's id, then for its suit, then the suit's
|
|
82
|
+
* own.
|
|
83
|
+
*/
|
|
84
|
+
readonly tone?: ChartTone | undefined;
|
|
85
|
+
/** `context` draws the card gray; the others yield to inspection, so a card recedes like any node. */
|
|
86
|
+
readonly emphasis?: MarkEmphasis | undefined;
|
|
87
|
+
/** False fades the card out and takes it out of the keyboard order. */
|
|
88
|
+
readonly isShown?: boolean | undefined;
|
|
89
|
+
/** True keeps the card at full strength while the rest recede. */
|
|
90
|
+
readonly isActive?: boolean | undefined;
|
|
91
|
+
/** The other face. Left out, a lattice in the card's tone; a playing card's is neutral so it hides the suit. */
|
|
92
|
+
readonly back?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* More on the face: for a playing card it replaces the big suit in the center, for a generic card it sits under the
|
|
95
|
+
* text.
|
|
96
|
+
*/
|
|
97
|
+
readonly children?: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* The stacking order. Left out, a stacked card draws above the cards under it, and a spread card above every pile, so
|
|
100
|
+
* a dealt card travels over the deck.
|
|
101
|
+
*/
|
|
102
|
+
readonly order?: number | undefined;
|
|
103
|
+
/** How long every change waits before the card moves. Prefer the stack's `stagger` to deal cards in turn. */
|
|
104
|
+
readonly delay?: SceneDelay | undefined;
|
|
105
|
+
/** Overrides the scene's pace for this card. */
|
|
106
|
+
readonly pace?: Pace | undefined;
|
|
107
|
+
readonly labels?: Partial<SceneCardLabels> | undefined;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A playing card, or a generic card with a word on it, that eases to its new place, face, lift and tilt. Name a rank
|
|
111
|
+
* and suit and it draws the corners and the suit, spoken as "Queen of Hearts". Place it with `at`, or list its id in a
|
|
112
|
+
* `SceneStack` declared before it, so a card dealt from one stack to another travels there.
|
|
113
|
+
*/
|
|
114
|
+
export declare function SceneCard({ id, at, offset, rotate, rank, suit, text, label, isFaceUp, lift, tilt, size, tone, emphasis, isShown, isActive, back, children, order, delay, pace, labels: labelInput, }: SceneCardProps): ReactNode;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { NumericDomain, ValueFormat } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { HeatmapPalette } from '../../../../charts/src/matrix/index.ts';
|
|
4
|
+
import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
|
|
5
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
6
|
+
import type { SceneCellInput, SceneCellsDirection, SceneCellSizeName, SceneCellValues } from './cell-grid.ts';
|
|
7
|
+
/** The words a grid of cells speaks. Placeholders in braces are filled in. */
|
|
8
|
+
export type SceneCellsLabels = {
|
|
9
|
+
/** A cell of a grid with several rows and columns. `{row}`, `{column}` and `{value}`. */
|
|
10
|
+
readonly cell: string;
|
|
11
|
+
/** A cell of a single row, such as a vector. `{column}` and `{value}`. */
|
|
12
|
+
readonly inRow: string;
|
|
13
|
+
/** A cell of a single column. `{row}` and `{value}`. */
|
|
14
|
+
readonly inColumn: string;
|
|
15
|
+
/** `{index}` counts from 1. */
|
|
16
|
+
readonly rowName: string;
|
|
17
|
+
readonly columnName: string;
|
|
18
|
+
/** `{id}` names the grid. */
|
|
19
|
+
readonly noCells: string;
|
|
20
|
+
readonly ragged: string;
|
|
21
|
+
/** `{id}` names the grid, `{labels}` how many labels it got and `{count}` how many rows or columns it has. */
|
|
22
|
+
readonly rowLabelCount: string;
|
|
23
|
+
readonly columnLabelCount: string;
|
|
24
|
+
};
|
|
25
|
+
/** The plain English words of a grid of cells. */
|
|
26
|
+
export declare const sceneCellsLabels: {
|
|
27
|
+
readonly cell: '{row}, {column}: {value}';
|
|
28
|
+
readonly inRow: '{column}: {value}';
|
|
29
|
+
readonly inColumn: '{row}: {value}';
|
|
30
|
+
readonly rowName: 'Row {index}';
|
|
31
|
+
readonly columnName: 'Column {index}';
|
|
32
|
+
readonly noCells: 'The cells "{id}" have nothing to draw. Give `values` or `cells`.';
|
|
33
|
+
readonly ragged: 'The cells "{id}" have rows of different lengths.';
|
|
34
|
+
readonly rowLabelCount: 'The cells "{id}" have {count} rows but {labels} row labels.';
|
|
35
|
+
readonly columnLabelCount: 'The cells "{id}" have {count} columns but {labels} column labels.';
|
|
36
|
+
};
|
|
37
|
+
export type SceneCellsProps = {
|
|
38
|
+
/**
|
|
39
|
+
* Stable across states. Name a cell `${id}.${row}.${column}`; as one object the grid is the box around its cells,
|
|
40
|
+
* where wires meet it, and the scene makes room for its labels too.
|
|
41
|
+
*/
|
|
42
|
+
readonly id: string;
|
|
43
|
+
/** The center of the cells in data units. Labels hang outside it. */
|
|
44
|
+
readonly at: ScenePosition;
|
|
45
|
+
/** The numbers: a flat list is one row (or one column with `direction`), a list of lists is a matrix. */
|
|
46
|
+
readonly values?: SceneCellValues | undefined;
|
|
47
|
+
/** Cells with text or ids, as a list of rows. Used instead of `values`. */
|
|
48
|
+
readonly cells?: ReadonlyArray<ReadonlyArray<SceneCellInput>> | undefined;
|
|
49
|
+
/** Which way a flat list of `values` runs. Defaults to `row`. */
|
|
50
|
+
readonly direction?: SceneCellsDirection | undefined;
|
|
51
|
+
/** How a number is written. Defaults to at most two decimals. A value that eases is formatted on every frame. */
|
|
52
|
+
readonly format?: ValueFormat | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Colors the cells on the matrix charts' scale: `sequential` shades one hue by size, `diverging` uses two hues around
|
|
55
|
+
* zero. Left out, the cells are plain.
|
|
56
|
+
*/
|
|
57
|
+
readonly palette?: HeatmapPalette | undefined;
|
|
58
|
+
/** The values the color spans. Left out: zero to the largest magnitude, or its mirror for `diverging`. */
|
|
59
|
+
readonly domain?: NumericDomain | undefined;
|
|
60
|
+
/** The named size of each cell. Defaults to `medium`. */
|
|
61
|
+
readonly size?: SceneCellSizeName | undefined;
|
|
62
|
+
/** One caption per row, drawn left of the grid in a column as wide as the longest. */
|
|
63
|
+
readonly rowLabels?: ReadonlyArray<string> | undefined;
|
|
64
|
+
/** One caption per column, drawn above the grid. */
|
|
65
|
+
readonly columnLabels?: ReadonlyArray<string> | undefined;
|
|
66
|
+
/** A row, a column, or one cell where both are given, drawn with a strong outline. Indices count from 0. */
|
|
67
|
+
readonly highlight?: {
|
|
68
|
+
readonly row?: number | undefined;
|
|
69
|
+
readonly column?: number | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
/** The readout sentence for the whole grid. With one, the arrow keys reach it. */
|
|
72
|
+
readonly label?: string | undefined;
|
|
73
|
+
/** `context` keeps the cells plain; the others yield to inspection. */
|
|
74
|
+
readonly emphasis?: MarkEmphasis | undefined;
|
|
75
|
+
/** False fades the grid out and takes its cells out of the keyboard order. */
|
|
76
|
+
readonly isShown?: boolean | undefined;
|
|
77
|
+
readonly labels?: Partial<SceneCellsLabels> | undefined;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A vector, a weight matrix or an embedding row drawn as a grid of numbered cells. Each cell is its own object with the
|
|
81
|
+
* id `${id}.${row}.${column}`, so wires and callouts can point at it. Its number counts to a new value and its color
|
|
82
|
+
* eases when `values` change, with the meaning of the matrix charts.
|
|
83
|
+
*/
|
|
84
|
+
export declare function SceneCells(props: SceneCellsProps): ReactNode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
|
|
4
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
5
|
+
import type { SceneCardSizeName } from './stack-layout.ts';
|
|
6
|
+
export type SceneSlotProps = {
|
|
7
|
+
/** Stable across states. Wires, brackets and callouts can name the slot. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
/** The slot's center in data units. */
|
|
10
|
+
readonly at: ScenePosition;
|
|
11
|
+
/**
|
|
12
|
+
* A named card size, with room around it for one card, or an exact pixel box for a row or a pile. Defaults to
|
|
13
|
+
* `medium`.
|
|
14
|
+
*/
|
|
15
|
+
readonly size?: SceneCardSizeName | {
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** The caption drawn above the top edge, such as "Bay A". The scene makes room for it. */
|
|
20
|
+
readonly text?: string | undefined;
|
|
21
|
+
/** The readout sentence. With one, the arrow keys reach the slot; Left and Right step on to a card sitting on it. */
|
|
22
|
+
readonly label?: string | undefined;
|
|
23
|
+
/** True draws the slot as the place that matters now: a solid outline and a tint. */
|
|
24
|
+
readonly isActive?: boolean | undefined;
|
|
25
|
+
/** The hue of the outline while active. Defaults to neutral. */
|
|
26
|
+
readonly tone?: ChartTone | undefined;
|
|
27
|
+
/** `context` keeps the slot plain; the others yield to inspection. */
|
|
28
|
+
readonly emphasis?: MarkEmphasis | undefined;
|
|
29
|
+
/** False fades the slot out and takes it out of the keyboard order. */
|
|
30
|
+
readonly isShown?: boolean | undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A labelled, outlined place where cards or other nodes go: a bay. Cards are not held by it; give them its position, or
|
|
34
|
+
* list them in a stack anchored at the same point. Name it in a wire or a callout, and set `isActive` for the bay in
|
|
35
|
+
* play.
|
|
36
|
+
*/
|
|
37
|
+
export declare function SceneSlot({ id, at, size, text, label, isActive, tone, emphasis, isShown, }: SceneSlotProps): ReactNode;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
3
|
+
import type { SceneStagger } from '../scene-stagger.ts';
|
|
4
|
+
import type { SceneCardSizeName, StackGapName, StackLayout } from './stack-layout.ts';
|
|
5
|
+
/** The words a stack speaks when its input is wrong. */
|
|
6
|
+
export type SceneStackLabels = {
|
|
7
|
+
/** `{id}` names the stack and `{card}` the card another stack lists too. */
|
|
8
|
+
readonly sharedCard: string;
|
|
9
|
+
/** `{id}` names the stack and `{card}` the card it lists twice. */
|
|
10
|
+
readonly repeatedCard: string;
|
|
11
|
+
};
|
|
12
|
+
/** The plain English words of a stack. */
|
|
13
|
+
export declare const sceneStackLabels: {
|
|
14
|
+
readonly sharedCard: 'The stack "{id}" lists the card "{card}", which another stack lists too. A card sits in one stack.';
|
|
15
|
+
readonly repeatedCard: 'The stack "{id}" lists the card "{card}" twice.';
|
|
16
|
+
};
|
|
17
|
+
export type SceneStackProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Stable across states. A wire, group, bracket, callout or the camera can name the stack: as one object it is the box
|
|
20
|
+
* around all its cards.
|
|
21
|
+
*/
|
|
22
|
+
readonly id: string;
|
|
23
|
+
/** The anchor in data units: the bottom card of a pile, the middle of a row, column or fan. */
|
|
24
|
+
readonly at: ScenePosition;
|
|
25
|
+
/** The ids of the `SceneCard`s in the stack, in order: bottom of a pile, left of a row, top of a column. */
|
|
26
|
+
readonly cards: ReadonlyArray<string>;
|
|
27
|
+
/** Defaults to `pile`. */
|
|
28
|
+
readonly layout?: StackLayout | undefined;
|
|
29
|
+
/** The room between cards in a row, column or fan. Defaults to `medium`. */
|
|
30
|
+
readonly gap?: StackGapName | undefined;
|
|
31
|
+
/** The card size every card in the stack takes. Defaults to `medium`. */
|
|
32
|
+
readonly size?: SceneCardSizeName | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Deals in turn: cards that arrive or move in the same update start this step apart, in stack order, and a card that
|
|
35
|
+
* moves alone starts at once. Left out, they all start together.
|
|
36
|
+
*/
|
|
37
|
+
readonly stagger?: SceneStagger | undefined;
|
|
38
|
+
/** The readout sentence. With one, the arrow keys reach the stack, which lights all its cards. */
|
|
39
|
+
readonly label?: string | undefined;
|
|
40
|
+
readonly labels?: Partial<SceneStackLabels> | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Places the cards it lists as a pile, a fan, a row or a column from one anchor, and keeps room in the scene for all of
|
|
44
|
+
* them. Declare it before its cards. Reorder, add or move ids between stacks and the cards ease or travel into place.
|
|
45
|
+
*/
|
|
46
|
+
export declare function SceneStack({ id, at, cards, layout, gap, size, stagger, label, labels: labelInput, }: SceneStackProps): ReactNode;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone, ValueFormat } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
|
|
4
|
+
import type { SceneOffset, ScenePosition } from '../scene-geometry.ts';
|
|
5
|
+
/** The words a token speaks. `{token}` is the quoted text, `{probability}` and `{id}` the numbers under it. */
|
|
6
|
+
export type SceneTokenLabels = {
|
|
7
|
+
readonly plain: string;
|
|
8
|
+
readonly withProbability: string;
|
|
9
|
+
readonly withId: string;
|
|
10
|
+
readonly withBoth: string;
|
|
11
|
+
};
|
|
12
|
+
/** The plain English words of a token. */
|
|
13
|
+
export declare const sceneTokenLabels: {
|
|
14
|
+
readonly plain: '{token}';
|
|
15
|
+
readonly withProbability: '{token}, probability {probability}';
|
|
16
|
+
readonly withId: '{token}, token id {id}';
|
|
17
|
+
readonly withBoth: '{token}, token id {id}, probability {probability}';
|
|
18
|
+
};
|
|
19
|
+
export type SceneTokenProps = {
|
|
20
|
+
/** Stable across states: the token with this id moves to its new props. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/** The token's center in data units. */
|
|
23
|
+
readonly at: ScenePosition;
|
|
24
|
+
/** A shift from `at` in pixels. `SceneTokens` uses it to lay a sequence out. */
|
|
25
|
+
readonly offset?: SceneOffset | undefined;
|
|
26
|
+
/** The token's exact text. Spaces, tabs and newlines show faint marks, as in the text charts. */
|
|
27
|
+
readonly text: string;
|
|
28
|
+
/** The vocabulary id, written under the text. */
|
|
29
|
+
readonly tokenId?: number | string | undefined;
|
|
30
|
+
/** A probability from 0 to 1, written under the text with a bar along the bottom. It eases when it changes. */
|
|
31
|
+
readonly probability?: number | undefined;
|
|
32
|
+
/** How the probability is written. Defaults to a percent with one decimal. */
|
|
33
|
+
readonly format?: ValueFormat | undefined;
|
|
34
|
+
/** The hue of the outline and the bar. Left out, a plain outline and a series bar. */
|
|
35
|
+
readonly tone?: ChartTone | undefined;
|
|
36
|
+
/** The readout sentence. Left out, the quoted text with its id and probability. */
|
|
37
|
+
readonly label?: string | undefined;
|
|
38
|
+
/** `context` draws the token plain; the others yield to inspection. */
|
|
39
|
+
readonly emphasis?: MarkEmphasis | undefined;
|
|
40
|
+
/** False fades the token out and takes it out of the keyboard order. */
|
|
41
|
+
readonly isShown?: boolean | undefined;
|
|
42
|
+
/** True keeps the token at full strength while the rest recede. */
|
|
43
|
+
readonly isActive?: boolean | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* True draws the token without making room for it in the scene's layout. `SceneTokens` sets it, because the sequence
|
|
46
|
+
* makes room for all its tokens at once.
|
|
47
|
+
*/
|
|
48
|
+
readonly isFloating?: boolean | undefined;
|
|
49
|
+
readonly labels?: Partial<SceneTokenLabels> | undefined;
|
|
50
|
+
};
|
|
51
|
+
/** How a token writes its probability unless told otherwise. */
|
|
52
|
+
export declare const tokenPercent: ValueFormat;
|
|
53
|
+
/** The text under a token, from its id and the probability as written. */
|
|
54
|
+
export declare function tokenCaption({ tokenId, probability, }: {
|
|
55
|
+
readonly tokenId: number | string | undefined;
|
|
56
|
+
readonly probability: string | undefined;
|
|
57
|
+
}): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* One token of text in the monospace face, with its vocabulary id or a probability under it, in the style of the text
|
|
60
|
+
* charts. Give it a position and it eases there; give it a new probability and its bar and number count to it. Its box
|
|
61
|
+
* is sized from its character count, never measured.
|
|
62
|
+
*/
|
|
63
|
+
export declare function SceneToken({ id, at, offset, text, tokenId, probability, format, tone, label, emphasis, isShown, isActive, isFloating, labels: labelInput, }: SceneTokenProps): ReactNode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChartTone, ValueFormat } from '../../../../charts/src/index.ts';
|
|
3
|
+
import type { MarkEmphasis } from '../../../../charts/src/plot/index.ts';
|
|
4
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
5
|
+
import type { TokenGapName } from './token-layout.ts';
|
|
6
|
+
/** One token of a sequence. Its scene id is `${sequence id}.${index}`. */
|
|
7
|
+
export type SceneTokenItem = {
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly tokenId?: number | string | undefined;
|
|
10
|
+
readonly probability?: number | undefined;
|
|
11
|
+
readonly tone?: ChartTone | undefined;
|
|
12
|
+
/** The readout sentence. Left out, the quoted text with its id and probability. */
|
|
13
|
+
readonly label?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type SceneTokensProps = {
|
|
16
|
+
/** Stable across states. Name one token as `${id}.${index}`; the sequence is the box around its rows. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
/** The center of the whole block in data units. */
|
|
19
|
+
readonly at: ScenePosition;
|
|
20
|
+
/** The sequence in reading order. */
|
|
21
|
+
readonly tokens: ReadonlyArray<SceneTokenItem>;
|
|
22
|
+
/** The width in pixels at which the row wraps to a new line. Defaults to 480. */
|
|
23
|
+
readonly wrapWidth?: number | undefined;
|
|
24
|
+
/** The room between tokens. Defaults to `medium`. */
|
|
25
|
+
readonly gap?: TokenGapName | undefined;
|
|
26
|
+
/** How probabilities are written. Defaults to a percent with one decimal. */
|
|
27
|
+
readonly format?: ValueFormat | undefined;
|
|
28
|
+
/** The readout sentence for the whole sequence. With one, the arrow keys reach it. */
|
|
29
|
+
readonly label?: string | undefined;
|
|
30
|
+
/** `context` draws every token plain; the others yield to inspection. */
|
|
31
|
+
readonly emphasis?: MarkEmphasis | undefined;
|
|
32
|
+
/** False fades the sequence out and takes its tokens out of the keyboard order. */
|
|
33
|
+
readonly isShown?: boolean | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A sequence of tokens laid out in a row that wraps, each with a stable id `${id}.${index}`. Add, remove or change
|
|
37
|
+
* tokens and the rest ease along. Use it for a prompt, a completion or a context window; the text charts draw the same
|
|
38
|
+
* tokens when the figure is data rather than a part of a diagram.
|
|
39
|
+
*/
|
|
40
|
+
export declare function SceneTokens({ id, at, tokens, wrapWidth, gap, format, label, emphasis, isShown, }: SceneTokensProps): ReactNode;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ScenePosition } from '../scene-geometry.ts';
|
|
2
|
+
import type { SceneStagger } from '../scene-stagger.ts';
|
|
3
|
+
import type { SceneCardSizeName, StackGapName, StackLayout } from './stack-layout.ts';
|
|
4
|
+
/** What a stack tells the cards it lists. */
|
|
5
|
+
export type StackSpec = {
|
|
6
|
+
readonly at: ScenePosition;
|
|
7
|
+
readonly layout: StackLayout;
|
|
8
|
+
readonly size: SceneCardSizeName;
|
|
9
|
+
readonly gap: StackGapName;
|
|
10
|
+
/** The ids of the cards in order: the bottom of a pile first, the left of a row first. */
|
|
11
|
+
readonly cards: ReadonlyArray<string>;
|
|
12
|
+
/** The step between cards that move in the same update, or undefined when they all start at once. */
|
|
13
|
+
readonly stagger: SceneStagger | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Where a card sits: the stack that lists it and its place in that stack's order. */
|
|
16
|
+
export type StackSlot = {
|
|
17
|
+
readonly stackId: string;
|
|
18
|
+
readonly spec: StackSpec;
|
|
19
|
+
readonly index: number;
|
|
20
|
+
};
|
|
21
|
+
/** The scene's record of its stacks, so a card finds its place without being nested inside its stack. */
|
|
22
|
+
export type StackBook = {
|
|
23
|
+
/** Records a stack without telling anyone, so cards rendered after it in one pass see it. Undefined removes it. */
|
|
24
|
+
readonly set: (id: string, spec: StackSpec | undefined) => void;
|
|
25
|
+
/** Tells the cards that a stack changed since the last flush. Call it from a layout effect. */
|
|
26
|
+
readonly flush: () => void;
|
|
27
|
+
readonly slotOf: (cardId: string) => StackSlot | undefined;
|
|
28
|
+
/** A card that this stack lists and another stack lists too, or undefined. */
|
|
29
|
+
readonly sharedCard: (stackId: string) => string | undefined;
|
|
30
|
+
/** Changes whenever a flush tells the cards something. Use it as the store snapshot. */
|
|
31
|
+
readonly version: () => number;
|
|
32
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
33
|
+
};
|
|
34
|
+
/** The stack book of a scene, made on first use and kept as long as the scene's registry lives. */
|
|
35
|
+
export declare const stackBookOf: (registry: import("../scene-registry.ts").SceneRegistry) => StackBook;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { SceneOffset } from '../scene-geometry.ts';
|
|
2
|
+
/** The pixel boxes of the named card sizes, in playing-card proportions. */
|
|
3
|
+
export declare const sceneCardSizes: {
|
|
4
|
+
readonly small: {
|
|
5
|
+
readonly width: 56;
|
|
6
|
+
readonly height: 78;
|
|
7
|
+
};
|
|
8
|
+
readonly medium: {
|
|
9
|
+
readonly width: 84;
|
|
10
|
+
readonly height: 118;
|
|
11
|
+
};
|
|
12
|
+
readonly large: {
|
|
13
|
+
readonly width: 144;
|
|
14
|
+
readonly height: 202;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** A named card size. */
|
|
18
|
+
export type SceneCardSizeName = keyof typeof sceneCardSizes;
|
|
19
|
+
/** The room between cards in a row, a column or a fan, by name, in CSS pixels. */
|
|
20
|
+
export declare const stackGaps: {
|
|
21
|
+
readonly small: 4;
|
|
22
|
+
readonly medium: 12;
|
|
23
|
+
readonly large: 24;
|
|
24
|
+
};
|
|
25
|
+
/** A named gap between the cards of a stack. */
|
|
26
|
+
export type StackGapName = keyof typeof stackGaps;
|
|
27
|
+
/**
|
|
28
|
+
* How a stack arranges its cards: stacked with a small step, overlapped along an arc, side by side, or one under
|
|
29
|
+
* another.
|
|
30
|
+
*/
|
|
31
|
+
export type StackLayout = 'pile' | 'fan' | 'row' | 'column';
|
|
32
|
+
/** What `stackOffset` and `stackBounds` need to know about a stack. */
|
|
33
|
+
export type StackShape = {
|
|
34
|
+
readonly layout: StackLayout;
|
|
35
|
+
/** How many cards the stack holds. */
|
|
36
|
+
readonly count: number;
|
|
37
|
+
readonly size: SceneCardSizeName;
|
|
38
|
+
readonly gap: StackGapName;
|
|
39
|
+
};
|
|
40
|
+
/** Where one card of a stack sits: its shift from the stack's anchor in pixels, and its turn in degrees. */
|
|
41
|
+
export type StackPlace = {
|
|
42
|
+
readonly offset: SceneOffset;
|
|
43
|
+
readonly rotate: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Where the card at `index` sits in a stack. A pile grows up and right from its bottom card; a row or column is
|
|
47
|
+
* centered on it, and a fan turns its cards out along an arc. The first card is the bottom of a pile, the left of a row
|
|
48
|
+
* or fan, and the top of a column.
|
|
49
|
+
*/
|
|
50
|
+
export declare function stackPlace({ layout, count, size, gap, index }: StackShape & {
|
|
51
|
+
readonly index: number;
|
|
52
|
+
}): StackPlace;
|
|
53
|
+
/** The pixel box around a whole stack: its center's shift from the anchor and its size. */
|
|
54
|
+
export type StackBounds = {
|
|
55
|
+
readonly offset: SceneOffset;
|
|
56
|
+
readonly width: number;
|
|
57
|
+
readonly height: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The box around every card of a stack, turned cards included, so a wire, a group, a bracket or the camera can address
|
|
61
|
+
* the stack as one object. An empty stack is one card's box.
|
|
62
|
+
*/
|
|
63
|
+
export declare function stackBounds(shape: StackShape): StackBounds;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SceneOffset } from '../scene-geometry.ts';
|
|
2
|
+
/** The pixels between neighbouring tokens, by name. */
|
|
3
|
+
export declare const tokenGaps: {
|
|
4
|
+
readonly small: 4;
|
|
5
|
+
readonly medium: 8;
|
|
6
|
+
readonly large: 16;
|
|
7
|
+
};
|
|
8
|
+
/** A named gap between tokens. */
|
|
9
|
+
export type TokenGapName = keyof typeof tokenGaps;
|
|
10
|
+
/** What decides a token's box: its text, and the text under it. */
|
|
11
|
+
export type TokenBoxInput = {
|
|
12
|
+
readonly text: string;
|
|
13
|
+
readonly caption: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** The pixel box of a token: wide enough for its characters, capped, and taller when a line sits under the text. */
|
|
16
|
+
export declare function tokenBox({ text, caption }: TokenBoxInput): {
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
};
|
|
20
|
+
/** Each token's center as a shift in pixels from the block's center, and the block's size. */
|
|
21
|
+
export type TokenFlow = {
|
|
22
|
+
readonly offsets: ReadonlyArray<SceneOffset>;
|
|
23
|
+
readonly width: number;
|
|
24
|
+
readonly height: number;
|
|
25
|
+
};
|
|
26
|
+
type TokenBox = {
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly height: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Lays token boxes out left to right and wraps to a new row when the next would pass `wrapWidth`. Rows are as tall as
|
|
32
|
+
* their tallest token. Offsets are from the block's center, so a block keeps its center as tokens come and go.
|
|
33
|
+
*/
|
|
34
|
+
export declare function tokenFlow({ boxes, wrapWidth, gap, }: {
|
|
35
|
+
readonly boxes: ReadonlyArray<TokenBox>;
|
|
36
|
+
readonly wrapWidth: number;
|
|
37
|
+
readonly gap: TokenGapName;
|
|
38
|
+
}): TokenFlow;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AnyLesson } from '../lesson/define-lesson.ts';
|
|
2
|
+
import type { LessonFinding } from './findings.ts';
|
|
3
|
+
/** A beat as the teaching advice reads it, from a plan or from a defined lesson. */
|
|
4
|
+
export type AdviceBeat = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly hasGoal: boolean;
|
|
8
|
+
/** The values each declared state sets. */
|
|
9
|
+
readonly states: ReadonlyArray<Readonly<Record<string, unknown>>>;
|
|
10
|
+
};
|
|
11
|
+
/** A lesson as the teaching advice reads it. */
|
|
12
|
+
export type AdviceOutline = {
|
|
13
|
+
/** The opening value of every param. */
|
|
14
|
+
readonly defaults: Readonly<Record<string, unknown>>;
|
|
15
|
+
readonly beats: ReadonlyArray<AdviceBeat>;
|
|
16
|
+
};
|
|
17
|
+
/** The teaching advice every lesson gets, from a plan or from a definition. */
|
|
18
|
+
export declare function outlineAdvice(outline: AdviceOutline): ReadonlyArray<LessonFinding>;
|
|
19
|
+
/**
|
|
20
|
+
* Teaching advice for a lesson made by `defineLesson`: beats with no goal, beats that introduce several params at once,
|
|
21
|
+
* params no state moves and long runs without a recap. The definition itself was checked when it was made.
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkLesson(lesson: AnyLesson): ReadonlyArray<LessonFinding>;
|