@algorisys/tinyfly 0.114.0 → 0.116.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.
Files changed (69) hide show
  1. package/README.md +13 -8
  2. package/docs/api-reference.md +2 -1
  3. package/docs/character-appearance.md +27 -2
  4. package/docs/editor-guide.md +1 -1
  5. package/docs/examples.md +1 -1
  6. package/docs/getting-started.md +1 -1
  7. package/docs/gsap-compat.md +1 -1
  8. package/docs/llm-guide.md +18 -0
  9. package/docs/maps.md +2 -2
  10. package/docs/math.md +280 -0
  11. package/docs/teaching.md +1 -1
  12. package/lib/addons/characters.js +2646 -2584
  13. package/lib/addons/{cricket-play-BZNhfgOK.js → cricket-play-C5CkNOc6.js} +2187 -2005
  14. package/lib/addons/math.js +2864 -0
  15. package/lib/addons/sports.js +1 -1
  16. package/lib/browser/tinyfly-math.iife.js +53 -0
  17. package/lib/browser/tinyfly.iife.js +12 -12
  18. package/lib/browser/tinyfly.js +4948 -4699
  19. package/lib/browser/tinyfly.umd.js +12 -12
  20. package/lib/embed/tinyfly-embed.iife.js +1 -1
  21. package/lib/embed/tinyfly-embed.js +8 -0
  22. package/lib/player/tinyfly-player.es.js +8 -0
  23. package/lib/player/tinyfly-player.iife.js +1 -1
  24. package/lib/player/tinyfly-player.umd.js +1 -1
  25. package/lib/types/characters/capabilities.d.ts +8 -0
  26. package/lib/types/characters/character.d.ts +4 -0
  27. package/lib/types/characters/index.d.ts +2 -0
  28. package/lib/types/characters/look/illustrated-pen.d.ts +36 -0
  29. package/lib/types/characters/look/illustration-color.d.ts +13 -0
  30. package/lib/types/characters/look/pen.d.ts +18 -5
  31. package/lib/types/math/browser-entry.d.ts +3 -0
  32. package/lib/types/math/embed/auto-mount-math.d.ts +7 -0
  33. package/lib/types/math/embed/explorable.d.ts +46 -0
  34. package/lib/types/math/embed/mount-math.d.ts +31 -0
  35. package/lib/types/math/expr/differentiate.d.ts +7 -0
  36. package/lib/types/math/expr/evaluate.d.ts +21 -0
  37. package/lib/types/math/expr/parse-expression.d.ts +50 -0
  38. package/lib/types/math/figure/derived.d.ts +17 -0
  39. package/lib/types/math/figure/display-list.d.ts +87 -0
  40. package/lib/types/math/figure/figure-spec.d.ts +239 -0
  41. package/lib/types/math/figure/item-context.d.ts +33 -0
  42. package/lib/types/math/figure/items/calculus.d.ts +7 -0
  43. package/lib/types/math/figure/items/curves.d.ts +7 -0
  44. package/lib/types/math/figure/items/grid.d.ts +5 -0
  45. package/lib/types/math/figure/items/regions.d.ts +5 -0
  46. package/lib/types/math/figure/items/text.d.ts +5 -0
  47. package/lib/types/math/figure/items/vectors.d.ts +9 -0
  48. package/lib/types/math/figure/layout-figure.d.ts +13 -0
  49. package/lib/types/math/figure/plane.d.ts +20 -0
  50. package/lib/types/math/figure/validate-spec.d.ts +2 -0
  51. package/lib/types/math/index.d.ts +43 -0
  52. package/lib/types/math/linear/mat2.d.ts +41 -0
  53. package/lib/types/math/linear/vec2.d.ts +18 -0
  54. package/lib/types/math/presets/calculus.d.ts +59 -0
  55. package/lib/types/math/presets/linear-algebra.d.ts +42 -0
  56. package/lib/types/math/render/arrow.d.ts +10 -0
  57. package/lib/types/math/render/display-list-to-svg.d.ts +10 -0
  58. package/lib/types/math/render/draw-display-list.d.ts +6 -0
  59. package/lib/types/math/steps/math-steps.d.ts +34 -0
  60. package/lib/types/math/targets/math-target.d.ts +43 -0
  61. package/lib/types/math/tex/equation-morph.d.ts +21 -0
  62. package/lib/types/math/tex/glyph-metrics.d.ts +24 -0
  63. package/lib/types/math/tex/tex-layout.d.ts +59 -0
  64. package/lib/types/math/tex/tex-parser.d.ts +88 -0
  65. package/lib/types/player/player.d.ts +6 -0
  66. package/llms-full.txt +388 -12
  67. package/llms.txt +32 -31
  68. package/package.json +6 -2
  69. package/skills/tinyfly/SKILL.md +13 -1
@@ -0,0 +1,10 @@
1
+ import type { Vec2 } from '../linear/vec2';
2
+ /**
3
+ * An arrow's geometry: the shaft (stopping where the head begins, so the line
4
+ * never pokes through the point) and the head's three corners. Pure; both
5
+ * renderers draw from it.
6
+ */
7
+ export declare function arrowGeometry(points: Vec2[], head: number): {
8
+ shaft: Vec2[];
9
+ head: [Vec2, Vec2, Vec2] | undefined;
10
+ };
@@ -0,0 +1,10 @@
1
+ import type { DisplayList } from '../figure/display-list';
2
+ /** The inner markup of a display list (what goes inside its `<svg>`). */
3
+ export declare function displayListToSvgContent(list: DisplayList): string;
4
+ /**
5
+ * A display list as a standalone SVG document: for embedding, static export,
6
+ * RSS, email and print. `title` becomes the figure's accessible name.
7
+ */
8
+ export declare function displayListToSvg(list: DisplayList, options?: {
9
+ title?: string;
10
+ }): string;
@@ -0,0 +1,6 @@
1
+ import type { DisplayList } from '../figure/display-list';
2
+ /**
3
+ * Draws a display list on a Canvas 2D context (a page, an OffscreenCanvas in a
4
+ * Worker, or @napi-rs/canvas in Node), clipped to the figure's box at 0, 0.
5
+ */
6
+ export declare function drawDisplayList(ctx: CanvasRenderingContext2D, list: DisplayList): void;
@@ -0,0 +1,34 @@
1
+ import type { AnimatableValue } from '../../engine/types';
2
+ import type { LessonBuilder, StepOptions } from '../../teach/lesson';
3
+ import type { MathFigureSpec } from '../figure/figure-spec';
4
+ /**
5
+ * Lesson steps for a maths figure, written on a `lesson()` builder from
6
+ * `@algorisys/tinyfly/teach`. Every helper writes ordinary tracks on the
7
+ * figure's target, so the result is plain timeline JSON with markers and
8
+ * captions, playable in the embed player, a video or the editor.
9
+ *
10
+ * const l = lesson({ id: 'shear' })
11
+ * const m = mathSteps(l, 'fig', figure, { hidden: ['basis'] })
12
+ * m.drawOn('basis')
13
+ * l.marker('basis', { label: 'î and ĵ', pause: true })
14
+ * m.applyMatrix([1, 1, 0, 1])
15
+ * l.marker('sheared', { label: 'A shear keeps î and moves ĵ', pause: true })
16
+ */
17
+ export interface MathSteps {
18
+ /** Animate a value (a number, vector or matrix) to `value` */
19
+ toValue(name: string, value: AnimatableValue, options?: StepOptions): MathSteps;
20
+ /** Move the matrix value (default `M`) to `matrix`: the plane transforms */
21
+ applyMatrix(matrix: number[], options?: StepOptions & {
22
+ name?: string;
23
+ }): MathSteps;
24
+ /** Draw an item on, like a pen (default 900 ms) */
25
+ drawOn(itemId: string, options?: StepOptions): MathSteps;
26
+ /** Fade an item in or out */
27
+ fadeIn(itemId: string, options?: StepOptions): MathSteps;
28
+ fadeOut(itemId: string, options?: StepOptions): MathSteps;
29
+ /** Move an equation to step `step`, its terms gliding (default 900 ms) */
30
+ showStep(itemId: string, step: number, options?: StepOptions): MathSteps;
31
+ }
32
+ export declare function mathSteps(l: LessonBuilder, target: string, figure: MathFigureSpec, options?: {
33
+ hidden?: string[];
34
+ }): MathSteps;
@@ -0,0 +1,43 @@
1
+ import type { AnimatableValue } from '../../engine/types';
2
+ import type { MathFigureSpec } from '../figure/figure-spec';
3
+ /**
4
+ * A maths figure as a canvas target: register it with a CanvasAdapter (or a
5
+ * headless video scene's `targets`) and a timeline animates its values and
6
+ * item props as plain tracks:
7
+ *
8
+ * { target: 'fig', property: 'M', keyframes: [{ time: 0, value: [1,0,0,1] }, { time: 1500, value: [2,1,0,1] }] }
9
+ * { target: 'fig', property: 'grid.draw', keyframes: … }
10
+ *
11
+ * It has the shape of the canvas adapter's custom target (`type: 'custom'`)
12
+ * without importing it, so the maths module stays independent of adapters.
13
+ */
14
+ export interface MathCanvasTarget {
15
+ type: 'custom';
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ props: Record<string, AnimatableValue>;
21
+ acceptsProp(property: string): boolean;
22
+ draw(ctx: CanvasRenderingContext2D, target: {
23
+ props?: Record<string, AnimatableValue>;
24
+ }): void;
25
+ about: {
26
+ kind: string;
27
+ summary: string;
28
+ props: Record<string, {
29
+ description: string;
30
+ kind?: 'number' | 'list';
31
+ unit?: string;
32
+ min?: number;
33
+ max?: number;
34
+ }>;
35
+ };
36
+ }
37
+ /** Every prop a figure accepts: its values by name, and each item's draw, opacity (and an equation's step). */
38
+ export declare function mathFigureProps(spec: MathFigureSpec): MathCanvasTarget['about']['props'];
39
+ /** A canvas target that draws `spec`, placed at x, y (its top left corner). */
40
+ export declare function mathTarget(spec: MathFigureSpec, place?: {
41
+ x?: number;
42
+ y?: number;
43
+ }): MathCanvasTarget;
@@ -0,0 +1,21 @@
1
+ import type { TexLayout, TexPiece } from './tex-layout';
2
+ /**
3
+ * One frame of a change from one typeset equation to the next, the way a
4
+ * teacher rewrites a line: terms that appear in both glide from their old
5
+ * place to their new one, terms that go fade out, terms that arrive fade in.
6
+ *
7
+ * Pieces pair by id (see tex-layout.ts: `x#1`, `=#1`, or an explicit
8
+ * `\id{name}`), in order within an id. A pair whose glyphs differ (a value
9
+ * that changed) cross-fades in place of gliding. Pure.
10
+ */
11
+ export type MorphPiece = TexPiece & {
12
+ opacity: number;
13
+ };
14
+ export interface PlacedLayout {
15
+ layout: TexLayout;
16
+ /** Where the layout's origin (left edge, baseline) sits, in the same units as the layout */
17
+ x: number;
18
+ y: number;
19
+ }
20
+ /** The pieces of the change at `progress` 0 (all `from`) to 1 (all `to`). */
21
+ export declare function morphEquation(from: PlacedLayout, to: PlacedLayout, progress: number): MorphPiece[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Fixed glyph metrics for typesetting equations, in ems.
3
+ *
4
+ * Equations are laid out from this table, never from a font's measurements,
5
+ * so the same TeX gives the same positions in a browser, a Web Worker and
6
+ * Node (the precedent is the whiteboard's and code panel's fixed cells).
7
+ * Each glyph is drawn centred in its advance, so a font that is a little
8
+ * wider or narrower than the table still sits where the layout put it.
9
+ *
10
+ * The widths approximate Computer Modern / Latin Modern, the faces listed
11
+ * first in MATH_FONT.
12
+ */
13
+ export declare const MATH_FONT = "\"Latin Modern Math\", \"STIX Two Math\", \"Cambria Math\", \"Times New Roman\", \"Liberation Serif\", \"Noto Serif\", Times, serif";
14
+ /** Height above the baseline of the maths axis (where fraction bars and − sit). */
15
+ export declare const AXIS_HEIGHT = 0.25;
16
+ /** Rule thickness for fraction bars and radicals. */
17
+ export declare const RULE = 0.05;
18
+ /** Advance width of one glyph, in ems at size 1. */
19
+ export declare function advance(text: string): number;
20
+ /** Height above and depth below the baseline, in ems at size 1. */
21
+ export declare function extent(text: string): {
22
+ height: number;
23
+ depth: number;
24
+ };
@@ -0,0 +1,59 @@
1
+ import { type TexNode } from './tex-parser';
2
+ /**
3
+ * Typesets a parsed TeX tree into positioned pieces, in ems.
4
+ *
5
+ * Coordinates: x grows right from the left edge, y grows DOWN from the
6
+ * baseline (screen convention), so a superscript has a negative y.
7
+ *
8
+ * Every piece carries an `id`. Plain symbols are numbered by their text and
9
+ * occurrence (`x#1`, `=#1`, `2#2`), so two steps of an equation pair up their
10
+ * matching terms with no extra markup; `\id{name}{…}` names a whole term
11
+ * explicitly. Pure: the same TeX and values always give the same layout.
12
+ */
13
+ export interface TexGlyph {
14
+ kind: 'glyph';
15
+ text: string;
16
+ /** Left edge of the glyph's advance cell; draw it centred in `width` */
17
+ x: number;
18
+ /** Baseline */
19
+ y: number;
20
+ width: number;
21
+ size: number;
22
+ italic: boolean;
23
+ color?: string;
24
+ id: string;
25
+ }
26
+ export interface TexRule {
27
+ kind: 'rule';
28
+ x: number;
29
+ /** Top edge */
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ color?: string;
34
+ id: string;
35
+ }
36
+ export interface TexStroke {
37
+ kind: 'stroke';
38
+ points: [number, number][];
39
+ width: number;
40
+ color?: string;
41
+ id: string;
42
+ }
43
+ export type TexPiece = TexGlyph | TexRule | TexStroke;
44
+ export interface TexLayout {
45
+ width: number;
46
+ /** Above the baseline */
47
+ height: number;
48
+ /** Below the baseline */
49
+ depth: number;
50
+ pieces: TexPiece[];
51
+ }
52
+ export interface TexLayoutOptions {
53
+ /** `display` (default) puts big-operator limits above and below; `inline` beside */
54
+ style?: 'display' | 'inline';
55
+ /** Live numbers for `\val{name}` */
56
+ values?: Record<string, number>;
57
+ }
58
+ /** Typeset TeX source (or an already-parsed tree) into pieces, in ems. */
59
+ export declare function layoutTex(source: string | TexNode, options?: TexLayoutOptions): TexLayout;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The TeX subset tinyfly typesets, parsed into a small tree.
3
+ *
4
+ * Supported:
5
+ * - Letters (italic), digits, `+ - = < > ( ) [ ] | , . ; : ! '`
6
+ * - `^` and `_` with a single token or a `{group}`
7
+ * - `\frac{a}{b}`, `\sqrt{x}`, `\vec{v}`, `\hat{x}`, `\bar{x}`
8
+ * - Big operators `\sum \prod \int` (limits from `_` and `^`), and named
9
+ * operators `\sin \cos \tan \log \ln \exp \det \lim \max \min \arg`
10
+ * - Greek letters and the symbols in SYMBOLS (`\cdot \times \le \to \infty` …)
11
+ * - `\begin{pmatrix} a & b \\ c & d \end{pmatrix}` (also `bmatrix`, `vmatrix`, `matrix`)
12
+ * - `\text{words}`, `\color{name or #hex}{…}`, spacing `\, \; \quad \qquad`
13
+ * - `\id{name}{…}`: names a term, so an equation step can move it to its
14
+ * place in the next step (see equation-morph.ts)
15
+ * - `\val{name}` or `\val{name:2}`: a live number from the figure's values,
16
+ * with up to that many decimals (default 2), so a matrix shown in TeX
17
+ * follows the matrix being animated
18
+ *
19
+ * Anything else is an error that names the position, never a silent guess.
20
+ */
21
+ export type TexClass = 'ord' | 'bin' | 'rel' | 'open' | 'close' | 'punct' | 'op';
22
+ export type TexNode = {
23
+ type: 'symbol';
24
+ text: string;
25
+ cls: TexClass;
26
+ italic: boolean;
27
+ } | {
28
+ type: 'group';
29
+ body: TexNode[];
30
+ } | {
31
+ type: 'scripts';
32
+ base: TexNode;
33
+ sup?: TexNode;
34
+ sub?: TexNode;
35
+ } | {
36
+ type: 'frac';
37
+ num: TexNode;
38
+ den: TexNode;
39
+ } | {
40
+ type: 'sqrt';
41
+ body: TexNode;
42
+ } | {
43
+ type: 'accent';
44
+ accent: 'vec' | 'hat' | 'bar';
45
+ body: TexNode;
46
+ } | {
47
+ type: 'bigop';
48
+ text: string;
49
+ limits: boolean;
50
+ } | {
51
+ type: 'opname';
52
+ text: string;
53
+ limits: boolean;
54
+ } | {
55
+ type: 'matrix';
56
+ delimiters: 'pmatrix' | 'bmatrix' | 'vmatrix' | 'matrix';
57
+ rows: TexNode[][];
58
+ } | {
59
+ type: 'text';
60
+ text: string;
61
+ } | {
62
+ type: 'color';
63
+ color: string;
64
+ body: TexNode;
65
+ } | {
66
+ type: 'id';
67
+ id: string;
68
+ body: TexNode;
69
+ } | {
70
+ type: 'value';
71
+ name: string;
72
+ digits: number;
73
+ } | {
74
+ type: 'space';
75
+ width: number;
76
+ };
77
+ /** Symbol commands: the glyph and its spacing class. */
78
+ export declare const SYMBOLS: Record<string, [string, TexClass]>;
79
+ export declare class TexError extends Error {
80
+ readonly source: string;
81
+ /** 0-based index into the source */
82
+ readonly position: number;
83
+ constructor(message: string, source: string, position: number);
84
+ }
85
+ /** Every command the parser knows, for "did you mean" messages and discovery. */
86
+ export declare const TEX_COMMANDS: string[];
87
+ /** Parse a TeX string into a group node. */
88
+ export declare function parseTex(source: string): TexNode;
@@ -247,6 +247,12 @@ export declare class TinyflyPlayer {
247
247
  * Get current playback time.
248
248
  */
249
249
  get currentTime(): number;
250
+ /**
251
+ * The animated values at the playhead, for renderers that draw from values
252
+ * rather than DOM elements (a canvas, or an SVG rebuilt each frame). Read it
253
+ * from a `subscribe` listener. Undefined before a timeline loads.
254
+ */
255
+ get state(): AnimationState | undefined;
250
256
  /**
251
257
  * Get total duration.
252
258
  */