@mechane-ai/elements 0.49.0 → 0.50.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 +40 -2
- package/dist/{article-yyNPg6VU.js → article-CRlhq9oA.js} +531 -463
- package/dist/article.js +1 -1
- package/dist/catalog.json +37 -1
- package/dist/{categorical-values-DCznViFp.js → categorical-values-BYP_R5gS.js} +13 -13
- package/dist/charts/cartesian.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 +1 -1
- 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 +7 -7
- package/dist/collections.js +1 -1
- package/dist/{dumbbell-plot-CMv9llfd.js → dumbbell-plot-BC8d_IJy.js} +45 -45
- package/dist/{embedding-map-DC-lgzCq.js → embedding-map-Bj8krO-d.js} +528 -528
- package/dist/figure-frame-koVKcXph.js +323 -0
- package/dist/{image-grid-DHqtj_zs.js → image-grid-CLhol2jy.js} +47 -47
- package/dist/kits/evaluation.js +50 -48
- package/dist/kits/interpretability.js +7 -7
- package/dist/kits/operations.js +4 -4
- package/dist/kits/research.js +346 -264
- package/dist/kits/training.js +3 -3
- package/dist/layout.js +1 -1075
- package/dist/lesson/spec.js +11 -11
- package/dist/lesson.js +4 -4
- package/dist/mdx.js +4 -4
- package/dist/packages/charts/src/chart-inspection.d.ts +4 -1
- package/dist/packages/charts/src/figure/caption-scope.d.ts +12 -0
- package/dist/packages/charts/src/figure/figure-frame.d.ts +2 -1
- package/dist/packages/charts/src/index.d.ts +2 -0
- package/dist/packages/collections/src/data-table-trigger.d.ts +2 -0
- package/dist/packages/kits/src/evaluation/leaderboard.d.ts +2 -0
- package/dist/packages/kits/src/research/collection-page.d.ts +46 -0
- package/dist/packages/kits/src/research/index.d.ts +2 -0
- package/dist/packages/kits/src/research/milestone-path.d.ts +1 -2
- package/dist/packages/kits/src/research/work-heartbeat.d.ts +4 -3
- package/dist/packages/layout/src/detail-page.d.ts +3 -1
- package/dist/packages/teaching/src/article/article-context.d.ts +2 -0
- package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +13 -0
- package/dist/packages/teaching/src/article/article.d.ts +6 -1
- package/dist/packages/teaching/src/article/figure.d.ts +20 -3
- package/dist/packages/teaching/src/article/index.d.ts +1 -1
- package/dist/packages/teaching/src/article/view-essay.d.ts +2 -1
- package/dist/packages/teaching/src/lesson/define-lesson.d.ts +4 -0
- package/dist/packages/teaching/src/lesson/index.d.ts +2 -2
- package/dist/packages/teaching/src/lesson/lesson-player.d.ts +19 -3
- package/dist/packages/teaching/src/lesson/lesson-store.d.ts +2 -0
- package/dist/packages/teaching/src/lesson/playback.d.ts +9 -6
- package/dist/packages/teaching/src/lesson/use-lesson.d.ts +7 -2
- package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +4 -1
- package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +5 -6
- package/dist/packages/teaching/src/scene/scene-geometry.d.ts +1 -1
- package/dist/packages/teaching/src/scene/scene-node.d.ts +4 -1
- package/dist/packages/teaching/src/scene/scene-validate.d.ts +6 -0
- package/dist/packages/teaching/src/scene/scene-wire.d.ts +6 -1
- package/dist/packages/teaching/src/scene/scene.d.ts +1 -1
- package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +5 -1
- package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +1 -1
- package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +1 -1
- package/dist/packages/teaching/src/time/tween.d.ts +2 -0
- package/dist/{param-BE3VMSkH.js → param-BdqTpZER.js} +166 -99
- package/dist/{plot-layout-Bqe4-0qZ.js → plot-layout-B2xRt-_k.js} +144 -130
- package/dist/{plot-surface-DON6WUmk.js → plot-surface-0cKFwtws.js} +1 -1
- package/dist/{reference-lines-hjuD1rRZ.js → reference-lines-nSxcZVF5.js} +1 -1
- package/dist/{scene-BP0Ue0R5.js → scene-4ePpWdmE.js} +1227 -1125
- package/dist/scene.js +1 -1
- package/dist/{slope-chart-C8eeSgL4.js → slope-chart-DWZIYDty.js} +179 -179
- package/dist/{src-B2rgpWap.js → src-DNclWY4V.js} +1 -1
- package/dist/src-DhWMspwr.js +1085 -0
- package/dist/styles2.css +77 -14
- package/dist/{time-series-BL933QyA.js → time-series-CsngFxr1.js} +952 -948
- package/dist/{token-heatmap-BB65awva.js → token-heatmap-BQLIxPky.js} +84 -84
- package/dist/{token-predictions-Pa8eUGan.js → token-predictions-C3B5L-eO.js} +126 -126
- package/dist/{transport-DzyxVXbL.js → transport-4V9rfYHN.js} +278 -233
- package/dist/{tree-diagram-DJhKBiia.js → tree-diagram-Dau9jeXS.js} +115 -115
- package/dist/{treemap-CxxgABUg.js → treemap-DWrMQndu.js} +27 -27
- package/dist/use-tween-BsaEO862.js +10 -0
- package/dist/{violin-plot-CoAEF_7Z.js → violin-plot-D05ODcyc.js} +123 -123
- package/dist/{waterfall-DdoEXEkT.js → waterfall-BkLLv2Lm.js} +39 -39
- package/package.json +1 -1
- package/recipes/counting-cards.tsx +3 -3
- package/skills/review-elements/SKILL.md +14 -0
- package/skills/review-explainer/SKILL.md +2 -1
- package/skills/upgrade-elements/references/releases.md +61 -0
- package/skills/use-elements/SKILL.md +21 -17
- package/skills/use-elements/references/editorial-restraint.md +40 -0
- package/skills/use-elements/references/styling.md +23 -0
- package/skills/use-elements/references/teaching.md +13 -0
- package/skills/use-elements/references/workspace.md +14 -8
- package/skills/write-explainer/references/article.md +50 -2
- package/skills/write-explainer/references/lesson.md +18 -9
- package/skills/write-explainer/references/scene-parts.md +17 -12
- package/skills/write-explainer/references/scene.md +25 -3
- package/dist/figure-frame-BjFzbl3m.js +0 -270
- package/dist/use-tween-5HZ55_9d.js +0 -72
|
@@ -6,6 +6,11 @@ export type SceneLabels = {
|
|
|
6
6
|
readonly objects: string;
|
|
7
7
|
/** The header of the exact-value table. */
|
|
8
8
|
readonly objectColumn: string;
|
|
9
|
+
/**
|
|
10
|
+
* Ends the plot's accessible name when a press acts, with `onSelectedChange`. Name the action, such as "Press Enter
|
|
11
|
+
* to turn the card over."
|
|
12
|
+
*/
|
|
13
|
+
readonly press: string;
|
|
9
14
|
readonly missingLocale: string;
|
|
10
15
|
readonly invalidBox: string;
|
|
11
16
|
readonly invalidAspect: string;
|
|
@@ -28,6 +33,7 @@ export type SceneLabels = {
|
|
|
28
33
|
export declare const sceneLabels: {
|
|
29
34
|
readonly objects: 'diagram parts';
|
|
30
35
|
readonly objectColumn: 'Part';
|
|
36
|
+
readonly press: 'Press Enter or Space to activate a part.';
|
|
31
37
|
readonly missingLocale: 'This scene needs a locale. Pass `locale`, or place it inside a Lesson.';
|
|
32
38
|
readonly invalidBox: 'The scene box needs two finite, increasing values on each axis.';
|
|
33
39
|
readonly invalidAspect: 'The scene aspect must be a positive, finite ratio of width to height.';
|
|
@@ -27,6 +27,11 @@ export type SceneWireProps = {
|
|
|
27
27
|
readonly tone?: ChartTone | undefined;
|
|
28
28
|
/** How the wire runs between its ends. Defaults to `straight`. */
|
|
29
29
|
readonly shape?: SceneWireShape | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Pixels the wire's middle bows off the line between its ends. Positive is above a wire that runs across and right of
|
|
32
|
+
* an upright one. A wire does not avoid other objects, so bow it around a node between its ends.
|
|
33
|
+
*/
|
|
34
|
+
readonly bend?: number | undefined;
|
|
30
35
|
/** Dashed for a modelled or proposed connection. */
|
|
31
36
|
readonly isDashed?: boolean | undefined;
|
|
32
37
|
/** Draws an arrowhead at the `to` end. Defaults to true. */
|
|
@@ -42,4 +47,4 @@ export type SceneWireProps = {
|
|
|
42
47
|
* A connection between two scene objects that stays attached to their edges while they move. Its thickness can carry a
|
|
43
48
|
* signed weight, eased when the weight changes. Give it a label to make it an item the reader can inspect.
|
|
44
49
|
*/
|
|
45
|
-
export declare function SceneWire({ from, to, id, label, text, textSide, weight, tone, shape, isDashed, hasArrow, isShown, isActive, emphasis, }: SceneWireProps): ReactNode;
|
|
50
|
+
export declare function SceneWire({ from, to, id, label, text, textSide, weight, tone, shape, bend, isDashed, hasArrow, isShown, isActive, emphasis, }: SceneWireProps): ReactNode;
|
|
@@ -19,7 +19,7 @@ export type SceneProps = Omit<FigureProps, 'locale'> & FigureSelectionProps & {
|
|
|
19
19
|
readonly pace?: Pace | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* The narrowest plot in pixels; below it the plot scrolls inside the frame. Left out, it is the width at which no
|
|
22
|
-
* two objects on
|
|
22
|
+
* two objects on one row touch and each wire keeps room for its arrow and text. Set it only to keep more room.
|
|
23
23
|
*/
|
|
24
24
|
readonly minWidth?: number | undefined;
|
|
25
25
|
/** The wire weight magnitude drawn thickest. Weights must lie within plus or minus this. Defaults to 1. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NumericDomain } from '../../../../charts/src/index.ts';
|
|
1
|
+
import type { ChartTone, NumericDomain } from '../../../../charts/src/index.ts';
|
|
2
2
|
import type { HeatmapPalette } from '../../../../charts/src/matrix/index.ts';
|
|
3
3
|
import type { SceneOffset } from '../scene-geometry.ts';
|
|
4
4
|
/** The pixel boxes of the named cell sizes. */
|
|
@@ -30,6 +30,10 @@ export type SceneCellInput = {
|
|
|
30
30
|
readonly value?: number | undefined;
|
|
31
31
|
/** The readout sentence. Left out, the cell says its row, column and value. */
|
|
32
32
|
readonly label?: string | undefined;
|
|
33
|
+
/** The hue of the cell's text and tint, such as a card's suit. A palette's fill still wins. */
|
|
34
|
+
readonly tone?: ChartTone | undefined;
|
|
35
|
+
/** True draws the cell gray and unfilled, such as a card already dealt. Its value and label stay. */
|
|
36
|
+
readonly isMuted?: boolean | undefined;
|
|
33
37
|
};
|
|
34
38
|
/** The numbers of a vector or a matrix: a flat list, or a list of rows. */
|
|
35
39
|
export type SceneCellValues = ReadonlyArray<number | ReadonlyArray<number>>;
|
|
@@ -61,7 +61,7 @@ export type SceneCellsProps = {
|
|
|
61
61
|
readonly size?: SceneCellSizeName | undefined;
|
|
62
62
|
/** One caption per row, drawn left of the grid in a column as wide as the longest. */
|
|
63
63
|
readonly rowLabels?: ReadonlyArray<string> | undefined;
|
|
64
|
-
/** One caption per column, drawn above the grid. */
|
|
64
|
+
/** One caption per column, drawn above the grid. A long caption wraps, and a word wider than its column overhangs. */
|
|
65
65
|
readonly columnLabels?: ReadonlyArray<string> | undefined;
|
|
66
66
|
/** A row, a column, or one cell where both are given, drawn with a strong outline. Indices count from 0. */
|
|
67
67
|
readonly highlight?: {
|
|
@@ -20,7 +20,7 @@ export type SceneSlotProps = {
|
|
|
20
20
|
readonly text?: string | undefined;
|
|
21
21
|
/** The readout sentence. With one, the arrow keys reach the slot; Left and Right step on to a card sitting on it. */
|
|
22
22
|
readonly label?: string | undefined;
|
|
23
|
-
/** True draws the slot as the place that matters now: a solid outline and a tint. */
|
|
23
|
+
/** True draws the slot as the place that matters now: a solid outline and a tint. Nothing else recedes. */
|
|
24
24
|
readonly isActive?: boolean | undefined;
|
|
25
25
|
/** The hue of the outline while active. Defaults to neutral. */
|
|
26
26
|
readonly tone?: ChartTone | undefined;
|
|
@@ -12,6 +12,8 @@ export type Tween<Key extends string> = {
|
|
|
12
12
|
/** Stops any move in flight. The tween still answers `get` and can be moved again. */
|
|
13
13
|
readonly destroy: () => void;
|
|
14
14
|
};
|
|
15
|
+
/** Fast at first and settling gently, the curve the motion tokens use for interface transitions. */
|
|
16
|
+
export declare function eased(progress: number): number;
|
|
15
17
|
/**
|
|
16
18
|
* Makes a tween that starts at `initial`. Give it a new target with `to` and read `get` on each change: authors
|
|
17
19
|
* describe where things are, and the tween supplies the motion between.
|
|
@@ -1,63 +1,126 @@
|
|
|
1
1
|
import { d as e, m as t } from "./src-Dxs3Buo_.js";
|
|
2
2
|
import { r as n } from "./figure-format-B8kRZMlo.js";
|
|
3
|
+
import { n as r, t as i } from "./clock-DSm5lkNE.js";
|
|
3
4
|
import "@stylexjs/stylex";
|
|
4
|
-
import { createParts as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { announce as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { Check as
|
|
9
|
-
import { SelectTrigger as
|
|
10
|
-
import { clamp as
|
|
5
|
+
import { createParts as a } from "@ui-sdk/react/primitive";
|
|
6
|
+
import { createContext as o, use as s, useEffect as c, useRef as l } from "react";
|
|
7
|
+
import { announce as u, bindDrag as d, createChange as f, definePrimitive as p, dragThreshold as m, isRTL as h } from "@ui-sdk/core";
|
|
8
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
9
|
+
import { Check as v, ChevronDown as y } from "lucide-react";
|
|
10
|
+
import { SelectTrigger as ee, SelectValue as te } from "@ui-sdk/react/select";
|
|
11
|
+
import { clamp as b, fractionOf as x, scrubTo as S, stepBy as ne, stepFromKey as re, stepValue as C, valueAt as w } from "@ui-sdk/core/number";
|
|
12
|
+
// packages/teaching/src/time/tween.ts
|
|
13
|
+
var T = {
|
|
14
|
+
instant: 0,
|
|
15
|
+
fast: 140,
|
|
16
|
+
regular: 320,
|
|
17
|
+
slow: 640
|
|
18
|
+
}, ie = 4;
|
|
19
|
+
function E() {}
|
|
20
|
+
function D(e) {
|
|
21
|
+
return 1 - (1 - e) ** ie;
|
|
22
|
+
}
|
|
23
|
+
function O(e, t) {
|
|
24
|
+
let n = new Map(Object.entries(t)), r = Object.entries(e);
|
|
25
|
+
return r.length === n.size && r.every(([e, t]) => n.get(e) === t);
|
|
26
|
+
}
|
|
27
|
+
function k(e, t, n) {
|
|
28
|
+
let r = new Map(Object.entries(e));
|
|
29
|
+
return {
|
|
30
|
+
...t,
|
|
31
|
+
...Object.fromEntries(Object.entries(t).map(([e, t]) => {
|
|
32
|
+
let i = r.get(e) ?? t;
|
|
33
|
+
return [e, i + (t - i) * n];
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function ae(e) {
|
|
38
|
+
let t = /* @__PURE__ */ new Set(), n = {
|
|
39
|
+
shown: e,
|
|
40
|
+
from: e,
|
|
41
|
+
target: e,
|
|
42
|
+
started: -1,
|
|
43
|
+
duration: 0,
|
|
44
|
+
stop: E
|
|
45
|
+
};
|
|
46
|
+
function a(e) {
|
|
47
|
+
n.shown = e;
|
|
48
|
+
for (let e of t) e();
|
|
49
|
+
}
|
|
50
|
+
function o() {
|
|
51
|
+
n.stop(), n.stop = E;
|
|
52
|
+
}
|
|
53
|
+
function s(e) {
|
|
54
|
+
o(), n.target = e, O(n.shown, e) || a(e);
|
|
55
|
+
}
|
|
56
|
+
function c(e) {
|
|
57
|
+
n.started < 0 && (n.started = e);
|
|
58
|
+
let t = Math.min(1, (e - n.started) / n.duration);
|
|
59
|
+
t >= 1 ? (o(), a(n.target)) : a(k(n.from, n.target, D(t)));
|
|
60
|
+
}
|
|
61
|
+
function l(e, t = "regular") {
|
|
62
|
+
O(n.target, e) || (T[t] === 0 || i() ? s(e) : (o(), n.from = n.shown, n.target = e, n.started = -1, n.duration = T[t], n.stop = r(c)));
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
get: () => n.shown,
|
|
66
|
+
to: l,
|
|
67
|
+
jump: s,
|
|
68
|
+
subscribe: (e) => (t.add(e), () => {
|
|
69
|
+
t.delete(e);
|
|
70
|
+
}),
|
|
71
|
+
destroy: o
|
|
72
|
+
};
|
|
73
|
+
}
|
|
11
74
|
// packages/teaching/src/lesson/lesson-locale.ts
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
return
|
|
75
|
+
var A = o(null);
|
|
76
|
+
function oe() {
|
|
77
|
+
return s(A);
|
|
15
78
|
}
|
|
16
79
|
// packages/teaching/src/lesson/lesson-error.tsx
|
|
17
|
-
function
|
|
80
|
+
function j(e, t) {
|
|
18
81
|
throw Error(`Lesson "${e}": ${t}`);
|
|
19
82
|
}
|
|
20
|
-
function
|
|
83
|
+
function M(e) {
|
|
21
84
|
throw Error(`${e} must be rendered inside a <Lesson>. Wrap it in <Lesson lesson={…} locale="…">.`);
|
|
22
85
|
}
|
|
23
|
-
function
|
|
24
|
-
return /* @__PURE__ */
|
|
86
|
+
function N({ children: e }) {
|
|
87
|
+
return /* @__PURE__ */ g("span", {
|
|
25
88
|
role: "note",
|
|
26
89
|
className: "xr5kp14 x1b5ytql",
|
|
27
90
|
children: e
|
|
28
91
|
});
|
|
29
92
|
}
|
|
30
93
|
// packages/teaching/src/lesson/define-lesson.ts
|
|
31
|
-
function
|
|
94
|
+
function P({ name: e, param: t, value: n }) {
|
|
32
95
|
switch (t.kind) {
|
|
33
96
|
case "number": return typeof n == "number" && Number.isFinite(n) && n >= t.min && n <= t.max ? void 0 : `${e} takes a number from ${t.min} to ${t.max}, not ${String(n)}.`;
|
|
34
97
|
case "choice": return t.options.some((e) => e.id === n) ? void 0 : `${e} takes one of ${t.options.map((e) => e.id).join(", ")}, not ${String(n)}.`;
|
|
35
98
|
case "toggle": return typeof n == "boolean" ? void 0 : `${e} takes true or false, not ${String(n)}.`;
|
|
36
99
|
}
|
|
37
100
|
}
|
|
38
|
-
function
|
|
101
|
+
function F(e, t) {
|
|
39
102
|
return Number.isFinite(t.min) && Number.isFinite(t.max) && t.min < t.max ? t.step > 0 ? t.scale === "log" && t.min <= 0 ? `${e} is on a log scale, so its min must be above zero.` : void 0 : `${e} needs a step above zero.` : `${e} needs finite bounds with min below max.`;
|
|
40
103
|
}
|
|
41
|
-
function
|
|
104
|
+
function I(e, t) {
|
|
42
105
|
if (t.kind === "number") {
|
|
43
|
-
let n =
|
|
106
|
+
let n = F(e, t);
|
|
44
107
|
if (n !== void 0) return n;
|
|
45
108
|
}
|
|
46
109
|
if (t.kind === "choice") {
|
|
47
110
|
let n = t.options.map((e) => e.id);
|
|
48
111
|
if (new Set(n).size !== n.length || n.length === 0) return `${e} needs at least one option, each with its own id.`;
|
|
49
112
|
}
|
|
50
|
-
let n =
|
|
113
|
+
let n = P({
|
|
51
114
|
name: e,
|
|
52
115
|
param: t,
|
|
53
116
|
value: t.value
|
|
54
117
|
});
|
|
55
118
|
return n === void 0 ? void 0 : `the default of ${n}`;
|
|
56
119
|
}
|
|
57
|
-
function
|
|
120
|
+
function L(e) {
|
|
58
121
|
return e.find((t, n) => e.indexOf(t) !== n);
|
|
59
122
|
}
|
|
60
|
-
function
|
|
123
|
+
function R(e) {
|
|
61
124
|
let t = /* @__PURE__ */ new Set();
|
|
62
125
|
return {
|
|
63
126
|
view: new Proxy(e, { get(e, n, r) {
|
|
@@ -66,12 +129,12 @@ function j(e) {
|
|
|
66
129
|
names: t
|
|
67
130
|
};
|
|
68
131
|
}
|
|
69
|
-
function
|
|
132
|
+
function z(e, t) {
|
|
70
133
|
let n = new Map(Object.entries(t));
|
|
71
134
|
return (e.states ?? []).flatMap((t) => Object.entries(t.values).flatMap(([r, i]) => {
|
|
72
135
|
let a = n.get(r), o = `state "${t.id}" of beat "${e.id}"`;
|
|
73
136
|
if (a === void 0) return [`${o} sets "${r}", which is not a param.`];
|
|
74
|
-
let s =
|
|
137
|
+
let s = P({
|
|
75
138
|
name: r,
|
|
76
139
|
param: a,
|
|
77
140
|
value: i
|
|
@@ -79,30 +142,34 @@ function M(e, t) {
|
|
|
79
142
|
return s === void 0 ? [] : [`${o}: ${s}`];
|
|
80
143
|
}));
|
|
81
144
|
}
|
|
82
|
-
function
|
|
83
|
-
let n = e.steps ?? 0, r = Number.isInteger(n) && n >= 0, i =
|
|
145
|
+
function B(e, t) {
|
|
146
|
+
let n = e.steps ?? 0, r = Number.isInteger(n) && n >= 0, i = L((e.states ?? []).map((e) => e.id)), a = (e.params ?? []).find((e) => !Object.hasOwn(t, e));
|
|
84
147
|
return [
|
|
85
148
|
...r ? [] : [`beat "${e.id}" needs a whole number of steps, not ${n}.`],
|
|
86
149
|
...i === void 0 ? [] : [`beat "${e.id}" has two states with the id "${i}".`],
|
|
87
|
-
...
|
|
150
|
+
...a === void 0 ? [] : [`beat "${e.id}" owns "${a}", which is not a param.`],
|
|
151
|
+
...z(e, t)
|
|
88
152
|
];
|
|
89
153
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
154
|
+
function V(e) {
|
|
155
|
+
return e.params ?? [...new Set((e.states ?? []).flatMap((e) => Object.keys(e.values)))];
|
|
156
|
+
}
|
|
157
|
+
function H({ params: e, derivedNames: t, beats: n }) {
|
|
158
|
+
let r = new Set(Object.keys(e)), i = t.find((e) => r.has(e)), a = L(n.map((e) => e.id));
|
|
92
159
|
return [
|
|
93
|
-
...Object.entries(e).flatMap(([e, t]) =>
|
|
160
|
+
...Object.entries(e).flatMap(([e, t]) => I(e, t) ?? []),
|
|
94
161
|
...i === void 0 ? [] : [`"${i}" is declared as both a param and a derived value.`],
|
|
95
162
|
...a === void 0 ? [] : [`two beats share the id "${a}".`],
|
|
96
|
-
...n.flatMap((t) =>
|
|
163
|
+
...n.flatMap((t) => B(t, e))
|
|
97
164
|
];
|
|
98
165
|
}
|
|
99
|
-
function
|
|
100
|
-
let { id: t, title: n, params: r } = e, i = Object.entries(e.derived ?? {}), a = e.beats ?? [], o = Object.keys(r), s = i.map(([e]) => e), [c] =
|
|
166
|
+
function U(e) {
|
|
167
|
+
let { id: t, title: n, params: r } = e, i = Object.entries(e.derived ?? {}), a = e.beats ?? [], o = Object.keys(r), s = i.map(([e]) => e), [c] = H({
|
|
101
168
|
params: r,
|
|
102
169
|
derivedNames: s,
|
|
103
170
|
beats: a
|
|
104
171
|
});
|
|
105
|
-
c !== void 0 &&
|
|
172
|
+
c !== void 0 && j(t, c);
|
|
106
173
|
let l = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, t.value])), u = Object.fromEntries(s.map((e) => [e, NaN]));
|
|
107
174
|
function d(e) {
|
|
108
175
|
let n = {
|
|
@@ -112,8 +179,8 @@ function F(e) {
|
|
|
112
179
|
},
|
|
113
180
|
results: u
|
|
114
181
|
}, r = new Set(o), a = i.map(([e, i]) => {
|
|
115
|
-
let { view: a, names: o } =
|
|
116
|
-
return c !== void 0 &&
|
|
182
|
+
let { view: a, names: o } = R(n.known), s = i.from(a), c = [...o].find((e) => !r.has(e));
|
|
183
|
+
return c !== void 0 && j(t, `derived "${e}" reads "${c}", which is not a param or a derived value declared before it.`), typeof s != "number" && j(t, `derived "${e}" must return a number.`), r.add(e), n.known = {
|
|
117
184
|
...n.known,
|
|
118
185
|
[e]: s
|
|
119
186
|
}, n.results = {
|
|
@@ -148,7 +215,7 @@ function F(e) {
|
|
|
148
215
|
reads: m
|
|
149
216
|
};
|
|
150
217
|
}
|
|
151
|
-
function
|
|
218
|
+
function W(e) {
|
|
152
219
|
return {
|
|
153
220
|
nodes: [...Object.entries(e.params).map(([e, t]) => ({
|
|
154
221
|
name: e,
|
|
@@ -166,21 +233,21 @@ function I(e) {
|
|
|
166
233
|
};
|
|
167
234
|
}
|
|
168
235
|
// packages/teaching/src/lesson/lesson-context.ts
|
|
169
|
-
var
|
|
170
|
-
function
|
|
171
|
-
return
|
|
236
|
+
var G = o(null);
|
|
237
|
+
function K(e) {
|
|
238
|
+
return s(G) ?? M(e);
|
|
172
239
|
}
|
|
173
|
-
function
|
|
240
|
+
function q(e, t) {
|
|
174
241
|
let n = { scope: e };
|
|
175
242
|
for (; n.scope !== null && n.scope.lesson !== t;) n.scope = n.scope.outer;
|
|
176
243
|
return n.scope;
|
|
177
244
|
}
|
|
178
245
|
// packages/teaching/src/lesson/bound-value.tsx
|
|
179
|
-
var
|
|
246
|
+
var se = 240, ce = {
|
|
180
247
|
step: .01,
|
|
181
248
|
large: .1,
|
|
182
249
|
small: .001
|
|
183
|
-
},
|
|
250
|
+
}, le = [
|
|
184
251
|
"ArrowLeft",
|
|
185
252
|
"ArrowRight",
|
|
186
253
|
"ArrowUp",
|
|
@@ -190,23 +257,23 @@ var B = 240, V = {
|
|
|
190
257
|
"Home",
|
|
191
258
|
"End"
|
|
192
259
|
];
|
|
193
|
-
function
|
|
260
|
+
function J({ min: e, max: t, step: n }) {
|
|
194
261
|
return {
|
|
195
262
|
min: e,
|
|
196
263
|
max: t,
|
|
197
264
|
step: n
|
|
198
265
|
};
|
|
199
266
|
}
|
|
200
|
-
function
|
|
201
|
-
let n =
|
|
202
|
-
return
|
|
267
|
+
function Y(e, t) {
|
|
268
|
+
let n = J(t);
|
|
269
|
+
return S(w(b(e, 0, 1), n, t.scale ?? "linear"), n).value;
|
|
203
270
|
}
|
|
204
|
-
function
|
|
271
|
+
function ue(e, t, n) {
|
|
205
272
|
if (t.bound !== void 0) return t.bound === "min" ? n.min : n.max;
|
|
206
|
-
let r =
|
|
207
|
-
return i === e ?
|
|
273
|
+
let r = J(n), i = Y(x(e, r, "log") + t.direction * ce[t.size], n);
|
|
274
|
+
return i === e ? C(e, t.direction, r) : i;
|
|
208
275
|
}
|
|
209
|
-
var
|
|
276
|
+
var de = p({
|
|
210
277
|
name: "bound-value",
|
|
211
278
|
options: {
|
|
212
279
|
value: "number",
|
|
@@ -225,7 +292,7 @@ var K = d({
|
|
|
225
292
|
}),
|
|
226
293
|
sync: (e) => e.value === void 0 ? {} : { value: e.value },
|
|
227
294
|
api: (e) => {
|
|
228
|
-
let { store: t } = e, n =
|
|
295
|
+
let { store: t } = e, n = f(e), r = null;
|
|
229
296
|
e.onDestroy(() => r?.());
|
|
230
297
|
function i(e, r, i) {
|
|
231
298
|
return e !== t.get().value && n("value", e, i === void 0 ? { reason: r } : {
|
|
@@ -238,27 +305,27 @@ var K = d({
|
|
|
238
305
|
setValue(t) {
|
|
239
306
|
let { min: n, max: r } = e.options(), a = Number(t);
|
|
240
307
|
if (!Number.isFinite(a) || a < n || a > r) throw Error(`Give a number between ${n} and ${r}.`);
|
|
241
|
-
return i(
|
|
308
|
+
return i(S(a, J(e.options())).value, "imperative");
|
|
242
309
|
},
|
|
243
310
|
keydown(n, r) {
|
|
244
|
-
let a =
|
|
311
|
+
let a = re(n, { dir: h(r) ? "rtl" : "ltr" });
|
|
245
312
|
if (a === null || n.defaultPrevented) return;
|
|
246
313
|
n.preventDefault();
|
|
247
314
|
let o = e.options(), { value: s } = t.get();
|
|
248
|
-
i(o.scale === "log" ?
|
|
315
|
+
i(o.scale === "log" ? ue(s, a, o) : ne(s, a, J(o)), "step-key", n);
|
|
249
316
|
},
|
|
250
317
|
pointerdown(n, a) {
|
|
251
318
|
if (n.button !== 0) return;
|
|
252
319
|
r?.();
|
|
253
|
-
let o = t.get().value, s =
|
|
254
|
-
r =
|
|
255
|
-
threshold:
|
|
320
|
+
let o = t.get().value, s = h(a) ? -1 : 1, c = x(o, J(e.options()), e.options().scale ?? "linear"), l = 0;
|
|
321
|
+
r = d(a, n, {
|
|
322
|
+
threshold: m,
|
|
256
323
|
cancelOnEscape: !0,
|
|
257
324
|
onStart: () => {
|
|
258
325
|
t.set({ isDragging: !0 });
|
|
259
326
|
},
|
|
260
327
|
onMove: ({ movementX: t, event: n }) => {
|
|
261
|
-
|
|
328
|
+
l += t * s, i(Y(c + l / se, e.options()), "drag", n);
|
|
262
329
|
},
|
|
263
330
|
onEnd: (e, n) => {
|
|
264
331
|
t.set({ isDragging: !1 }), n && i(o, "drag", e);
|
|
@@ -270,7 +337,7 @@ var K = d({
|
|
|
270
337
|
slots: (e) => ({ root: e({
|
|
271
338
|
role: "slider",
|
|
272
339
|
focus: "tab-stop",
|
|
273
|
-
keys: [...
|
|
340
|
+
keys: [...le],
|
|
274
341
|
state: (e, { api: t }) => ({
|
|
275
342
|
text: t.describe(e.value),
|
|
276
343
|
isDragging: e.isDragging
|
|
@@ -291,16 +358,16 @@ var K = d({
|
|
|
291
358
|
}
|
|
292
359
|
}) }),
|
|
293
360
|
agent: { actions: ["setValue"] }
|
|
294
|
-
}),
|
|
295
|
-
function
|
|
361
|
+
}), fe = a(de, { root: "span" }).Root;
|
|
362
|
+
function pe({ min: e, max: t, step: n, scale: r, value: i }) {
|
|
296
363
|
if (!Number.isFinite(e) || !Number.isFinite(t) || e >= t) return "BoundValue needs finite bounds with min below max.";
|
|
297
364
|
if (!Number.isFinite(n) || n < 0) return "BoundValue needs a step of zero or more.";
|
|
298
365
|
if (r === "log" && e <= 0) return "A log BoundValue needs a min above zero.";
|
|
299
366
|
if (i !== void 0 && !(Number.isFinite(i) && i >= e && i <= t)) return `BoundValue ${i} lies outside ${e} to ${t}.`;
|
|
300
367
|
}
|
|
301
|
-
function
|
|
302
|
-
let a =
|
|
303
|
-
return a === void 0 ? /* @__PURE__ */
|
|
368
|
+
function X({ label: e, locale: t, format: r, ...i }) {
|
|
369
|
+
let a = pe(i);
|
|
370
|
+
return a === void 0 ? /* @__PURE__ */ g(fe, {
|
|
304
371
|
...i,
|
|
305
372
|
describe: (e) => n({
|
|
306
373
|
value: e,
|
|
@@ -312,43 +379,43 @@ function Y({ label: e, locale: t, format: r, ...i }) {
|
|
|
312
379
|
"aria-valuemax": i.max,
|
|
313
380
|
"aria-orientation": "horizontal",
|
|
314
381
|
className: "xt0psk2 x1ok0vyi xbixft xss6m8b xk4h15q xuxw1ft x7eptgl x87ps6o xx69xxh xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x81ozek xxxv2na x13qnu6 x9v5kkp x19rmrnh x7s97pk",
|
|
315
|
-
render: (e, { text: t }) => /* @__PURE__ */
|
|
382
|
+
render: (e, { text: t }) => /* @__PURE__ */ g("span", {
|
|
316
383
|
...e,
|
|
317
384
|
children: t
|
|
318
385
|
})
|
|
319
|
-
}) : /* @__PURE__ */
|
|
386
|
+
}) : /* @__PURE__ */ g("span", {
|
|
320
387
|
className: "xr5kp14 x1b5ytql",
|
|
321
388
|
children: a
|
|
322
389
|
});
|
|
323
390
|
}
|
|
324
391
|
// packages/teaching/src/lesson/inline-choice.tsx
|
|
325
|
-
var
|
|
326
|
-
function
|
|
392
|
+
var me = 14;
|
|
393
|
+
function he({ param: e, value: n, isDisabled: r, onChange: i }) {
|
|
327
394
|
let a = e.options.map((e) => ({
|
|
328
395
|
value: e.id,
|
|
329
396
|
label: e.label
|
|
330
397
|
}));
|
|
331
|
-
return /* @__PURE__ */
|
|
398
|
+
return /* @__PURE__ */ _(t.Root, {
|
|
332
399
|
value: n,
|
|
333
400
|
items: a,
|
|
334
401
|
disabled: r,
|
|
335
402
|
onValueChange: (e, t) => {
|
|
336
403
|
e !== null && i(e, t);
|
|
337
404
|
},
|
|
338
|
-
children: [/* @__PURE__ */
|
|
405
|
+
children: [/* @__PURE__ */ _(ee, {
|
|
339
406
|
"aria-label": e.label,
|
|
340
407
|
disabled: r,
|
|
341
408
|
className: "x3nfvp2 x1pha0wt xfko13i x1717udv x1ghz6dp xc342km x1ok0vyi xjbqb8w xbixft xjb2p0i x1qlqyl8 x15bjb6t xk4h15q xuxw1ft x1ypdohk xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x1m8qfh3 x47ym49 x13qnu6 x9v5kkp x19rmrnh x7s97pk",
|
|
342
|
-
children: [/* @__PURE__ */
|
|
343
|
-
size:
|
|
409
|
+
children: [/* @__PURE__ */ g(te, {}), !r && /* @__PURE__ */ g(y, {
|
|
410
|
+
size: me,
|
|
344
411
|
"aria-hidden": !0,
|
|
345
412
|
className: "xamitd3 x153jb6y"
|
|
346
413
|
})]
|
|
347
|
-
}), /* @__PURE__ */
|
|
414
|
+
}), /* @__PURE__ */ g(t.Popup, {
|
|
348
415
|
align: "start",
|
|
349
|
-
children: /* @__PURE__ */
|
|
416
|
+
children: /* @__PURE__ */ g(t.List, { children: a.map((e) => /* @__PURE__ */ _(t.Item, {
|
|
350
417
|
value: e.value,
|
|
351
|
-
children: [/* @__PURE__ */
|
|
418
|
+
children: [/* @__PURE__ */ g(t.ItemText, { children: e.label }), /* @__PURE__ */ g(t.ItemIndicator, { children: /* @__PURE__ */ g(v, {
|
|
352
419
|
size: 16,
|
|
353
420
|
"aria-hidden": !0
|
|
354
421
|
}) })]
|
|
@@ -357,15 +424,15 @@ function oe({ param: e, value: n, isDisabled: r, onChange: i }) {
|
|
|
357
424
|
});
|
|
358
425
|
}
|
|
359
426
|
// packages/teaching/src/lesson/param.tsx
|
|
360
|
-
var
|
|
427
|
+
var ge = 700, Z = {
|
|
361
428
|
on: "on",
|
|
362
429
|
off: "off"
|
|
363
430
|
};
|
|
364
|
-
function
|
|
431
|
+
function Q(e, t) {
|
|
365
432
|
let n = new Map(Object.entries(e.lesson.params)).get(t);
|
|
366
433
|
return n === void 0 ? { error: `Lesson "${e.lesson.id}" has no param "${t}". Its params: ${Object.keys(e.lesson.params).join(", ")}.` } : { param: n };
|
|
367
434
|
}
|
|
368
|
-
function
|
|
435
|
+
function $({ param: e, value: t, locale: r, labels: i }) {
|
|
369
436
|
switch (e.kind) {
|
|
370
437
|
case "number": return n({
|
|
371
438
|
value: typeof t == "number" ? t : null,
|
|
@@ -376,20 +443,20 @@ function Q({ param: e, value: t, locale: r, labels: i }) {
|
|
|
376
443
|
case "toggle": return t === !0 ? i.on : i.off;
|
|
377
444
|
}
|
|
378
445
|
}
|
|
379
|
-
function
|
|
380
|
-
let n =
|
|
381
|
-
if ("error" in r) return /* @__PURE__ */
|
|
446
|
+
function _e({ name: t }) {
|
|
447
|
+
let n = K("Param"), r = Q(n, t);
|
|
448
|
+
if ("error" in r) return /* @__PURE__ */ g(N, { children: r.error });
|
|
382
449
|
let { param: i } = r, a = n.state.values[t], { isReadOnly: o } = n.state;
|
|
383
450
|
switch (i.kind) {
|
|
384
|
-
case "number": return o ? /* @__PURE__ */
|
|
451
|
+
case "number": return o ? /* @__PURE__ */ g("span", {
|
|
385
452
|
className: "xss6m8b xk4h15q xuxw1ft xbixft",
|
|
386
|
-
children:
|
|
453
|
+
children: $({
|
|
387
454
|
param: i,
|
|
388
455
|
value: a,
|
|
389
456
|
locale: n.locale,
|
|
390
|
-
labels:
|
|
457
|
+
labels: Z
|
|
391
458
|
})
|
|
392
|
-
}) : /* @__PURE__ */
|
|
459
|
+
}) : /* @__PURE__ */ g(X, {
|
|
393
460
|
value: typeof a == "number" ? a : i.value,
|
|
394
461
|
onValueChange: (e, r) => n.api.apply(t, e, r),
|
|
395
462
|
min: i.min,
|
|
@@ -400,41 +467,41 @@ function ce({ name: t }) {
|
|
|
400
467
|
format: i.format,
|
|
401
468
|
label: i.label
|
|
402
469
|
});
|
|
403
|
-
case "choice": return /* @__PURE__ */
|
|
470
|
+
case "choice": return /* @__PURE__ */ g(he, {
|
|
404
471
|
param: i,
|
|
405
472
|
value: typeof a == "string" ? a : i.value,
|
|
406
473
|
isDisabled: o,
|
|
407
474
|
onChange: (e, r) => n.api.apply(t, e, r)
|
|
408
475
|
});
|
|
409
|
-
case "toggle": return /* @__PURE__ */
|
|
476
|
+
case "toggle": return /* @__PURE__ */ g("span", {
|
|
410
477
|
className: "x3nfvp2 xxymvpz",
|
|
411
|
-
children: /* @__PURE__ */
|
|
478
|
+
children: /* @__PURE__ */ g(e.Root, {
|
|
412
479
|
checked: a === !0,
|
|
413
480
|
onCheckedChange: (e, r) => n.api.apply(t, e, r),
|
|
414
481
|
disabled: o,
|
|
415
482
|
"aria-label": i.label,
|
|
416
|
-
children: /* @__PURE__ */
|
|
483
|
+
children: /* @__PURE__ */ g(e.Thumb, {})
|
|
417
484
|
})
|
|
418
485
|
});
|
|
419
486
|
}
|
|
420
487
|
}
|
|
421
|
-
function
|
|
422
|
-
let n =
|
|
423
|
-
|
|
488
|
+
function ve(e, t) {
|
|
489
|
+
let n = l(e);
|
|
490
|
+
c(() => {
|
|
424
491
|
if (t || n.current === e) return;
|
|
425
492
|
let r = globalThis.setTimeout(() => {
|
|
426
|
-
n.current = e,
|
|
427
|
-
},
|
|
493
|
+
n.current = e, u(e);
|
|
494
|
+
}, ge);
|
|
428
495
|
return () => globalThis.clearTimeout(r);
|
|
429
496
|
}, [e, t]);
|
|
430
497
|
}
|
|
431
|
-
function
|
|
432
|
-
let r =
|
|
498
|
+
function ye({ name: e, labels: t }) {
|
|
499
|
+
let r = K("Value"), i = new Map(Object.entries(r.lesson.derived)).get(e), a = i === void 0 ? Q(r, e) : void 0, o = r.values[e], s = i === void 0 ? a !== void 0 && "param" in a ? $({
|
|
433
500
|
param: a.param,
|
|
434
501
|
value: o,
|
|
435
502
|
locale: r.locale,
|
|
436
503
|
labels: {
|
|
437
|
-
...
|
|
504
|
+
...Z,
|
|
438
505
|
...t
|
|
439
506
|
}
|
|
440
507
|
}) : void 0 : n({
|
|
@@ -442,9 +509,9 @@ function $({ name: e, labels: t }) {
|
|
|
442
509
|
locale: r.locale,
|
|
443
510
|
format: i.format
|
|
444
511
|
}), c = i?.label ?? (a !== void 0 && "param" in a ? a.param.label : e);
|
|
445
|
-
return
|
|
512
|
+
return ve(s === void 0 ? "" : `${c}: ${s}`, r.state.playing !== null), s === void 0 ? /* @__PURE__ */ g(N, { children: `Lesson "${r.lesson.id}" has no param or derived value "${e}".` }) : /* @__PURE__ */ g("span", {
|
|
446
513
|
className: "xss6m8b xk4h15q xuxw1ft",
|
|
447
514
|
children: s
|
|
448
515
|
});
|
|
449
516
|
}
|
|
450
|
-
export {
|
|
517
|
+
export { ae as _, G as a, V as c, P as d, N as f, oe as g, A as h, X as i, U as l, M as m, ye as n, q as o, j as p, Q as r, K as s, _e as t, W as u, D as v };
|