@beeson-group/tycho 0.1.0 → 0.3.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 (44) hide show
  1. package/AUTHORS +8 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +14 -0
  4. package/README.md +38 -0
  5. package/THIRD_PARTY_NOTICES.md +68 -0
  6. package/dist/tycho.esm.js +1517 -760
  7. package/dist/tycho.js +1517 -760
  8. package/dist/types/container.d.ts +64 -0
  9. package/dist/types/errors.d.ts +9 -0
  10. package/dist/types/evaluate/clock.d.ts +36 -0
  11. package/dist/types/evaluate/frames.d.ts +63 -0
  12. package/dist/types/evaluate/index.d.ts +21 -0
  13. package/dist/types/evaluate/layers.d.ts +108 -0
  14. package/dist/types/evaluate/resolve.d.ts +50 -0
  15. package/dist/types/evaluate/sets.d.ts +50 -0
  16. package/dist/types/evaluate/timeline.d.ts +60 -0
  17. package/dist/types/evaluate/types.d.ts +87 -0
  18. package/dist/types/index.d.ts +22 -0
  19. package/dist/types/runtime/colormaps.d.ts +10 -0
  20. package/dist/types/runtime/colors.d.ts +121 -0
  21. package/dist/types/runtime/element.d.ts +290 -0
  22. package/dist/types/runtime/export.d.ts +129 -0
  23. package/dist/types/runtime/geometry.d.ts +217 -0
  24. package/dist/types/runtime/icons.d.ts +66 -0
  25. package/dist/types/runtime/layout.d.ts +34 -0
  26. package/dist/types/runtime/outline.d.ts +29 -0
  27. package/dist/types/runtime/overlay.d.ts +33 -0
  28. package/dist/types/runtime/paint.d.ts +110 -0
  29. package/dist/types/runtime/raster.d.ts +33 -0
  30. package/dist/types/runtime/readouts.d.ts +136 -0
  31. package/dist/types/runtime/renderer.d.ts +551 -0
  32. package/dist/types/runtime/state.d.ts +104 -0
  33. package/dist/types/runtime/tiles.d.ts +33 -0
  34. package/dist/types/scene.d.ts +51 -0
  35. package/dist/types/scene.gen.d.ts +2033 -0
  36. package/dist/types/validate.d.ts +9 -0
  37. package/package.json +63 -35
  38. package/src/colormaps.ts +0 -42
  39. package/src/container.ts +0 -126
  40. package/src/element.ts +0 -1034
  41. package/src/frames.ts +0 -204
  42. package/src/index.ts +0 -14
  43. package/src/layout.ts +0 -82
  44. package/src/viewer.ts +0 -864
@@ -0,0 +1,136 @@
1
+ import { type PanelScope } from '../evaluate/resolve.js';
2
+ import type { SetCache } from '../evaluate/sets.js';
3
+ import type { Control, Panel, Scene, SetQuery, State, TextPart } from '../scene.js';
4
+ import { type GeometryCache } from './geometry.js';
5
+ /**
6
+ * A number for a readout. With `digits`, it is written to `digits` significant digits with trailing
7
+ * zeros kept. Otherwise an integer is written as it is, and any other number to six significant
8
+ * digits with trailing zeros dropped. An exponent is written as `e` and the exponent, and a minus sign as U+2212.
9
+ */
10
+ export declare function formatNumber(x: number, digits?: number, decimals?: number, grouping?: boolean): string;
11
+ /** The slider's stops, which are the distinct parameter values of the matched trajectory sets in increasing order (section 2.9). */
12
+ export declare function sliderStops(scope: PanelScope, sets: SetCache, control: Extract<Control, {
13
+ kind: 'slider';
14
+ }>): number[];
15
+ /** The index of the stop nearest a value, the lowest index winning a tie, or -1 when `stops` is empty. */
16
+ export declare function nearestStop(stops: readonly number[], value: number): number;
17
+ export { REVOLUTION_SECONDS, loopSeconds } from '../evaluate/timeline.js';
18
+ /**
19
+ * The loop position, in frame indices and unwrapped, `time` after a playback showed frame index
20
+ * `start`, with `perSecond` units of time to the second. A loop of `frameCount` frames lasts `seconds / speed`
21
+ * seconds. Live playback counts milliseconds and a video export its frames, and one division of
22
+ * exact products keeps a position that should be an integer exact.
23
+ */
24
+ export declare function loopPosition(start: number, time: number, perSecond: number, frameCount: number, speed: number, seconds: number): number;
25
+ /** The frame index at a loop position, i.e. its integer part wrapped into [0, frameCount). */
26
+ export declare function positionIndex(x: number, frameCount: number): number;
27
+ /** The progress q in [0, 1) at a loop position, which lies between two frame indices while playing. */
28
+ export declare function positionProgress(x: number, frameCount: number): number;
29
+ /** The panel, the state, and the frame index through which a readout reads. A caption without a panel does not read anything. */
30
+ export interface ReadoutContext {
31
+ scene: Scene;
32
+ geometry: GeometryCache;
33
+ state: State;
34
+ /** The panel whose reference and values the readout reads. */
35
+ panel: string;
36
+ frameIndex: number;
37
+ /** The progress at which the channel parts read, between two frame indices while playing. It defaults to frameIndex / frameCount. */
38
+ progress?: number;
39
+ }
40
+ type Part = TextPart;
41
+ /** The text of a readout. A part that the reference cannot give, because its query does not match any set, reads as a dash. */
42
+ export declare function readoutText(ctx: ReadoutContext, parts: readonly Part[]): string;
43
+ /** The text of each part of a readout, one per part, or an empty list when the panel is missing. */
44
+ export declare function readoutPieces(ctx: ReadoutContext, parts: readonly Part[]): string[];
45
+ /** One stat tile of a readout: its label, the index of its value part, and its unit. */
46
+ export interface ReadoutTile {
47
+ label: string;
48
+ part: number;
49
+ unit: string;
50
+ /** The least width of the value in ch, for a value that changes during playback (a channel or the clock), so that it does not move its neighbors. */
51
+ width: number | null;
52
+ }
53
+ /**
54
+ * A readout as stat tiles, or null when its text does not split. Parts are flat text, hence the
55
+ * split is a heuristic. A value's label is the text after the last comma before it, less a
56
+ * trailing "=" or ":", and its unit is the text after it up to the next comma. It fails when a
57
+ * label is empty, when the text between two values does not have a comma to split at, or when any
58
+ * text would be left over. Attribute parts, which are scene constants, go last.
59
+ */
60
+ export declare function readoutTiles(parts: readonly Part[]): ReadoutTile[] | null;
61
+ /** How a second of playback went: draws presented, late ones, and the display's refresh interval. */
62
+ export interface FrameReport {
63
+ /** Draws presented in the last second. */
64
+ drawn: number;
65
+ /** Draws that came more than half a refresh interval after the one they should have followed. */
66
+ late: number;
67
+ /** The estimated refresh interval of the display in milliseconds. */
68
+ refresh: number;
69
+ }
70
+ /**
71
+ * Counts the draws presented in the last second, as the Playback group shows it. An average of
72
+ * intervals hides a dropped refresh among smooth ones. The meter therefore keeps the presentation
73
+ * times themselves. The refresh interval is estimated as the shortest interval that recurs, taken as the
74
+ * 10th percentile of the window, and a draw is late when its interval exceeds the refresh interval by half.
75
+ */
76
+ export declare class FrameMeter {
77
+ private readonly times;
78
+ reset(): void;
79
+ /** Records a draw presented at `now`, in milliseconds, and forgets those over a second old. */
80
+ note(now: number): void;
81
+ /** The report of the last second, or null until a full second of draws has been seen since the last reset or after a stall. */
82
+ report(now: number): FrameReport | null;
83
+ }
84
+ /** The Playback group's frame rate, which shows the draws in the last second, or dashes while paused or before a second has passed. */
85
+ export declare function fpsText(report: FrameReport | null): string;
86
+ /** The tooltip behind the frame rate. */
87
+ export declare function fpsTitle(report: FrameReport | null): string;
88
+ export type KeyAction = {
89
+ kind: 'toggle';
90
+ } | {
91
+ kind: 'step';
92
+ by: number;
93
+ } | {
94
+ kind: 'seek';
95
+ frame: number;
96
+ } | {
97
+ kind: 'fit';
98
+ } | {
99
+ kind: 'slider';
100
+ by: number;
101
+ } | {
102
+ kind: 'view';
103
+ axis: 'x' | 'y' | 'z';
104
+ sign: 1 | -1;
105
+ } | {
106
+ kind: 'turn';
107
+ degrees: number;
108
+ };
109
+ /**
110
+ * The action of a key, following common video players. Space or k plays and pauses. The left and right
111
+ * arrows step one frame and pause, and ten with Shift. Home or 0 goes to frame 0, and a digit from 1 to 9
112
+ * goes to as many tenths of the loop. The key f fits every panel. The up and down arrows step the first
113
+ * shared slider by one stop, or by ten with Shift. In a panel with a 3d camera, x, y, and z show
114
+ * the view from the positive side of that axis, and from the negative side with Shift, and "," and "." turn
115
+ * it about the camera's up axis by 15 degrees, where "." turns it as a drag to the right does. Shift with
116
+ * either turns it by 90 degrees. Shift with them gives "<" and ">" on a US keyboard and other characters
117
+ * elsewhere, hence the two keys are then known by `code`, the `code` of the key event.
118
+ */
119
+ export declare function keyAction(key: string, shift: boolean, frameCount: number, code?: string): KeyAction | null;
120
+ /** Whether a focused form control takes `key` itself, given the tag name and the `type` of the control. */
121
+ export declare function controlUsesKey(tag: string, type: string, key: string): boolean;
122
+ /** The shared input of kind parameter that dragging a colorbar sets, with the label of its control and the trajectory sets that its stops come from. */
123
+ export interface ColorbarLink {
124
+ input: string;
125
+ label: string;
126
+ domain: SetQuery;
127
+ }
128
+ /**
129
+ * The parameter input that a colorbar of the declared panel `panel` sets. It is found from the bar's label, through a trajectory
130
+ * layer colored by a parameter whose label the bar carries and a shared input of kind parameter over the
131
+ * same parameter. The stops come from the parameter input's slider domain, else from the layer's sets.
132
+ * The result is null when a matching layer or a matching parameter input does not exist.
133
+ */
134
+ export declare function colorbarLink(scene: Scene, panel: Panel, barLabel: string): ColorbarLink | null;
135
+ /** The index of the stop nearest the value at `t` in [0, 1] along a bar from `lo` to `hi`, or -1 when `stops` is empty. */
136
+ export declare function stopAt(stops: readonly number[], lo: number, hi: number, t: number): number;