math-notation 0.1.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/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/CurlyBraceListOption.svg +3 -0
- package/dist/formulize.cjs.js +24587 -0
- package/dist/formulize.cjs.js.map +1 -0
- package/dist/formulize.es.js +24569 -0
- package/dist/formulize.es.js.map +1 -0
- package/dist/formulize.svg +9 -0
- package/dist/formulize.umd.js +24582 -0
- package/dist/formulize.umd.js.map +1 -0
- package/dist/mass.svg +25 -0
- package/dist/show-expression-border.svg +15 -0
- package/dist/show-expression-shadow.svg +4 -0
- package/dist/show-formula-border.svg +15 -0
- package/dist/show-formula-shadow.svg +4 -0
- package/dist/show-label-border.svg +15 -0
- package/dist/show-label-shadow.svg +4 -0
- package/dist/show-step-border.svg +15 -0
- package/dist/show-step-shadow.svg +4 -0
- package/dist/show-var-border.svg +15 -0
- package/dist/show-var-shadow.svg +4 -0
- package/dist/style.css +3000 -0
- package/dist/types/index.d.ts +1764 -0
- package/dist/velocity.svg +30 -0
- package/package.json +156 -0
|
@@ -0,0 +1,1764 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
declare class Accent extends AugmentedFormulaNodeBase {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
base: AugmentedFormulaNode;
|
|
7
|
+
type: "accent";
|
|
8
|
+
constructor(id: string, label: string, base: AugmentedFormulaNode);
|
|
9
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
10
|
+
withChanges({ id, parent, leftSibling, rightSibling, label, base, }: {
|
|
11
|
+
id?: string;
|
|
12
|
+
parent?: AugmentedFormulaNode | null;
|
|
13
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
14
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
15
|
+
label?: string;
|
|
16
|
+
base?: AugmentedFormulaNode;
|
|
17
|
+
}): Accent;
|
|
18
|
+
get children(): AugmentedFormulaNode[];
|
|
19
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class Aligned extends AugmentedFormulaNodeBase {
|
|
23
|
+
id: string;
|
|
24
|
+
body: AugmentedFormulaNode[][];
|
|
25
|
+
type: "array";
|
|
26
|
+
constructor(id: string, body: AugmentedFormulaNode[][]);
|
|
27
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
28
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, }: {
|
|
29
|
+
id?: string;
|
|
30
|
+
parent?: AugmentedFormulaNode | null;
|
|
31
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
32
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
33
|
+
body?: AugmentedFormulaNode[][];
|
|
34
|
+
}): Aligned;
|
|
35
|
+
get children(): AugmentedFormulaNode[];
|
|
36
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare class AugmentedFormula {
|
|
40
|
+
children: AugmentedFormulaNode[];
|
|
41
|
+
private idToNode;
|
|
42
|
+
constructor(children: AugmentedFormulaNode[]);
|
|
43
|
+
toLatex(mode: LatexMode): string;
|
|
44
|
+
toLatexRanges(mode: LatexMode): LatexRange;
|
|
45
|
+
findNode(id: string): AugmentedFormulaNode | null;
|
|
46
|
+
equals(other: AugmentedFormula): boolean;
|
|
47
|
+
toStyledRanges(): FormulaLatexRanges;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare type AugmentedFormulaNode = Script | Fraction | MathSymbol | Color | Group | Box | Brace | Text_2 | Space | Aligned | Root | Accent | Op | Strikethrough | Variable_2 | Matrix | Delimited;
|
|
51
|
+
|
|
52
|
+
declare abstract class AugmentedFormulaNodeBase {
|
|
53
|
+
id: string;
|
|
54
|
+
_parent: AugmentedFormulaNode | null;
|
|
55
|
+
_leftSibling: AugmentedFormulaNode | null;
|
|
56
|
+
_rightSibling: AugmentedFormulaNode | null;
|
|
57
|
+
/**
|
|
58
|
+
* The CSS ID assigned to this node's DOM element during variable processing.
|
|
59
|
+
* This corresponds to the \cssId{} wrapper in the rendered LaTeX.
|
|
60
|
+
* Set by processVariables when wrapping elements with cssId.
|
|
61
|
+
*/
|
|
62
|
+
cssId: string | null;
|
|
63
|
+
constructor(id: string);
|
|
64
|
+
protected latexWithId(mode: LatexMode, elements: RangeElement[]): RangeElement[];
|
|
65
|
+
get ancestors(): AugmentedFormulaNode[];
|
|
66
|
+
contains(id: string): boolean;
|
|
67
|
+
abstract toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
68
|
+
abstract get children(): AugmentedFormulaNode[];
|
|
69
|
+
abstract toStyledRanges(): FormulaLatexRangeNode[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare const BayesProbabilityChart: default_2.FC<BayesProbabilityChartProps>;
|
|
73
|
+
|
|
74
|
+
declare interface BayesProbabilityChartProps {
|
|
75
|
+
context: IContext;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare class Box extends AugmentedFormulaNodeBase {
|
|
79
|
+
id: string;
|
|
80
|
+
borderColor: string;
|
|
81
|
+
backgroundColor: string;
|
|
82
|
+
body: AugmentedFormulaNode;
|
|
83
|
+
type: "box";
|
|
84
|
+
constructor(id: string, borderColor: string, backgroundColor: string, body: AugmentedFormulaNode);
|
|
85
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
86
|
+
withChanges({ id, parent, leftSibling, rightSibling, borderColor, backgroundColor, body, }: {
|
|
87
|
+
id?: string;
|
|
88
|
+
parent?: AugmentedFormulaNode | null;
|
|
89
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
90
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
91
|
+
borderColor?: string;
|
|
92
|
+
backgroundColor?: string;
|
|
93
|
+
body?: AugmentedFormulaNode;
|
|
94
|
+
}): Box;
|
|
95
|
+
get children(): AugmentedFormulaNode[];
|
|
96
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare class Brace extends AugmentedFormulaNodeBase {
|
|
100
|
+
id: string;
|
|
101
|
+
over: boolean;
|
|
102
|
+
base: AugmentedFormulaNode;
|
|
103
|
+
type: "brace";
|
|
104
|
+
constructor(id: string, over: boolean, base: AugmentedFormulaNode);
|
|
105
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
106
|
+
withChanges({ id, parent, leftSibling, rightSibling, over, base, }: {
|
|
107
|
+
id?: string;
|
|
108
|
+
parent?: AugmentedFormulaNode | null;
|
|
109
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
110
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
111
|
+
over?: boolean;
|
|
112
|
+
base?: AugmentedFormulaNode;
|
|
113
|
+
}): Brace;
|
|
114
|
+
get children(): AugmentedFormulaNode[];
|
|
115
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare class Color extends AugmentedFormulaNodeBase {
|
|
119
|
+
id: string;
|
|
120
|
+
color: string;
|
|
121
|
+
body: AugmentedFormulaNode[];
|
|
122
|
+
type: "color";
|
|
123
|
+
constructor(id: string, color: string, body: AugmentedFormulaNode[]);
|
|
124
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
125
|
+
withChanges({ id, parent, leftSibling, rightSibling, color, body, }: {
|
|
126
|
+
id?: string;
|
|
127
|
+
parent?: AugmentedFormulaNode | null;
|
|
128
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
129
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
130
|
+
color?: string;
|
|
131
|
+
body?: AugmentedFormulaNode[];
|
|
132
|
+
}): Color;
|
|
133
|
+
get children(): AugmentedFormulaNode[];
|
|
134
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare class ComputationStore {
|
|
138
|
+
accessor variables: Map<string, IVariable>;
|
|
139
|
+
accessor hoverStates: Map<string, boolean>;
|
|
140
|
+
accessor dragStates: Map<string, boolean>;
|
|
141
|
+
accessor nodeHoverStates: Map<string, boolean>;
|
|
142
|
+
accessor formulaHoverStates: Map<string, boolean>;
|
|
143
|
+
private formulaHoverCallbacks;
|
|
144
|
+
accessor formulaNodeMapping: Map<string, string>;
|
|
145
|
+
accessor nodeFormulaMapping: Map<string, string>;
|
|
146
|
+
accessor formulaTrees: Map<string, AugmentedFormula>;
|
|
147
|
+
accessor formulaRenderSpecs: Map<string, RenderSpec | null>;
|
|
148
|
+
accessor formulaSuppressEditorUpdate: Map<string, boolean>;
|
|
149
|
+
accessor formulaStyledRangesOverride: Map<string, FormulaLatexRanges | null>;
|
|
150
|
+
accessor semantics: ISemantics | null;
|
|
151
|
+
accessor formulas: IFormula[];
|
|
152
|
+
accessor environment: IEnvironment | null;
|
|
153
|
+
accessor variableRolesChanged: number;
|
|
154
|
+
accessor isDragging: boolean;
|
|
155
|
+
accessor variableDimensions: Map<string, {
|
|
156
|
+
x: number;
|
|
157
|
+
y: number;
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
}>;
|
|
161
|
+
accessor injectedDefaultCSS: Map<string, string>;
|
|
162
|
+
accessor injectedHoverCSS: Map<string, string>;
|
|
163
|
+
accessor stepping: boolean;
|
|
164
|
+
/** All collected steps from the latest semantics execution */
|
|
165
|
+
accessor steps: ICollectedStep[];
|
|
166
|
+
/** Current step index being viewed (0-based) */
|
|
167
|
+
accessor currentStepIndex: number;
|
|
168
|
+
/** Error message if step collection failed */
|
|
169
|
+
accessor stepError: string | null;
|
|
170
|
+
/**
|
|
171
|
+
* Separate storage for step mode values - completely isolated from main variables.
|
|
172
|
+
* Only components observing stepValues will re-render when step values change.
|
|
173
|
+
* This is similar to how plot data (lines, surfaces) is stored separately.
|
|
174
|
+
*/
|
|
175
|
+
accessor stepValues: Map<string, IValue>;
|
|
176
|
+
/**
|
|
177
|
+
* Version counter for step values - incremented when stepValues changes.
|
|
178
|
+
* Components can observe this to know when to re-read stepValues.
|
|
179
|
+
*/
|
|
180
|
+
accessor stepValuesVersion: number;
|
|
181
|
+
/**
|
|
182
|
+
* Data points collected during step sampling.
|
|
183
|
+
* Maps graph ID to array of {x, y} points in execution order.
|
|
184
|
+
* Used by visualizations to show accumulated points based on step progress.
|
|
185
|
+
*/
|
|
186
|
+
accessor stepDataPointMap: Map<string, IDataPoint[]>;
|
|
187
|
+
private evaluationFunction;
|
|
188
|
+
isStepMode(): boolean;
|
|
189
|
+
setStepping(enabled: boolean): void;
|
|
190
|
+
/** Get the current step being viewed */
|
|
191
|
+
get currentStep(): ICollectedStep | undefined;
|
|
192
|
+
/** Get the total number of collected steps */
|
|
193
|
+
get totalSteps(): number;
|
|
194
|
+
/** Check if we're at the first step */
|
|
195
|
+
get isAtStart(): boolean;
|
|
196
|
+
/** Check if we're at the last step */
|
|
197
|
+
get isAtEnd(): boolean;
|
|
198
|
+
/** Get progress as a percentage (0-100) */
|
|
199
|
+
get stepProgress(): number;
|
|
200
|
+
/**
|
|
201
|
+
* Set the collected steps from semantics execution.
|
|
202
|
+
* Resets the current step index to 0 and updates stepValues immediately.
|
|
203
|
+
*/
|
|
204
|
+
setSteps(steps: ICollectedStep[]): void;
|
|
205
|
+
/**
|
|
206
|
+
* Navigate to the next step.
|
|
207
|
+
* Does nothing if already at the last step.
|
|
208
|
+
*/
|
|
209
|
+
nextStep(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Navigate to the previous step.
|
|
212
|
+
* Does nothing if already at the first step.
|
|
213
|
+
*/
|
|
214
|
+
prevStep(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Navigate to a specific step by index.
|
|
217
|
+
* Clamps the index to valid range.
|
|
218
|
+
*/
|
|
219
|
+
goToStep(index: number): void;
|
|
220
|
+
/**
|
|
221
|
+
* Go to the first step.
|
|
222
|
+
*/
|
|
223
|
+
goToStart(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Go to the last step.
|
|
226
|
+
*/
|
|
227
|
+
goToEnd(): void;
|
|
228
|
+
/**
|
|
229
|
+
* Set an error message for step collection.
|
|
230
|
+
*/
|
|
231
|
+
setStepError(error: string | null): void;
|
|
232
|
+
/**
|
|
233
|
+
* Reset step-related state only.
|
|
234
|
+
*/
|
|
235
|
+
resetSteps(): void;
|
|
236
|
+
/**
|
|
237
|
+
* Get the view for a specific formula from the current step.
|
|
238
|
+
* Returns the view for the given formulaId, or the default view (empty string key).
|
|
239
|
+
*
|
|
240
|
+
* @param formulaId - The formula ID to get the view for
|
|
241
|
+
* @returns The view for the formula, or undefined if not found
|
|
242
|
+
*/
|
|
243
|
+
getViewForFormula(formulaId: string): IView | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Get all variable values from the current step.
|
|
246
|
+
* Merges values from all formula views if multi-formula step.
|
|
247
|
+
*
|
|
248
|
+
* @returns Map of variable ID to value
|
|
249
|
+
*/
|
|
250
|
+
getCurrentStepValues(): Map<string, IValue>;
|
|
251
|
+
/**
|
|
252
|
+
* Get active variable IDs grouped by formula from the current step.
|
|
253
|
+
* Used for applying visual cues to updated variables.
|
|
254
|
+
*
|
|
255
|
+
* @returns Map of formula ID to Set of variable IDs
|
|
256
|
+
*/
|
|
257
|
+
getActiveVariables(): Map<string, Set<string>>;
|
|
258
|
+
get evaluateFormula(): EvaluationFunction | null;
|
|
259
|
+
/**
|
|
260
|
+
* Get the display value for a variable.
|
|
261
|
+
* In step mode, returns the value from stepValues (isolated step data).
|
|
262
|
+
* In normal mode, returns the value from the main variables map.
|
|
263
|
+
*
|
|
264
|
+
* @param varId - The variable ID
|
|
265
|
+
* @returns The value to display, or undefined if not found
|
|
266
|
+
*/
|
|
267
|
+
getDisplayValue(varId: string): IValue | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* Update stepValues from the current step's data.
|
|
270
|
+
* This is called when navigating steps or when input changes in step mode.
|
|
271
|
+
* Only updates the stepValues map - does NOT touch the main variables map.
|
|
272
|
+
*/
|
|
273
|
+
updateStepValues(): void;
|
|
274
|
+
/**
|
|
275
|
+
* Sample the current step and update stepValues.
|
|
276
|
+
* Used when input variables change in step mode.
|
|
277
|
+
* This re-runs the semantics to get fresh values for the current step.
|
|
278
|
+
*/
|
|
279
|
+
refreshCurrentStepValues(): void;
|
|
280
|
+
/**
|
|
281
|
+
* Create a snapshot copy of all variables for sampling/computation.
|
|
282
|
+
* Uses toJS to create deep copies that won't affect the original observables.
|
|
283
|
+
*/
|
|
284
|
+
getVariablesSnapshot(): Record<string, IVariable>;
|
|
285
|
+
setSemantics(config: ISemantics | null): void;
|
|
286
|
+
reset(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Store a processed formula tree for later DOM element lookup
|
|
289
|
+
* @param formulaId - The formula ID
|
|
290
|
+
* @param tree - The AugmentedFormula tree with cssId values assigned
|
|
291
|
+
*/
|
|
292
|
+
setFormulaTree(formulaId: string, tree: AugmentedFormula): void;
|
|
293
|
+
/**
|
|
294
|
+
* Get the stored formula tree for a formula
|
|
295
|
+
* @param formulaId - The formula ID
|
|
296
|
+
* @returns The AugmentedFormula tree or undefined if not found
|
|
297
|
+
*/
|
|
298
|
+
getFormulaTree(formulaId: string): AugmentedFormula | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Clear all stored formula trees
|
|
301
|
+
*/
|
|
302
|
+
clearFormulaTrees(): void;
|
|
303
|
+
/**
|
|
304
|
+
* Get the render spec for a formula
|
|
305
|
+
* @param formulaId - The formula ID
|
|
306
|
+
* @returns The RenderSpec or null if not found
|
|
307
|
+
*/
|
|
308
|
+
getFormulaRenderSpec(formulaId: string): RenderSpec | null;
|
|
309
|
+
/**
|
|
310
|
+
* Get the augmented formula for a formula ID
|
|
311
|
+
* @param formulaId - The formula ID
|
|
312
|
+
* @returns The AugmentedFormula or a default empty one
|
|
313
|
+
*/
|
|
314
|
+
getAugmentedFormula(formulaId: string): AugmentedFormula;
|
|
315
|
+
/**
|
|
316
|
+
* Get the suppress editor update flag for a formula
|
|
317
|
+
* @param formulaId - The formula ID
|
|
318
|
+
* @returns Whether editor updates should be suppressed
|
|
319
|
+
*/
|
|
320
|
+
getSuppressEditorUpdate(formulaId: string): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Get the styled ranges override for a formula
|
|
323
|
+
* @param formulaId - The formula ID
|
|
324
|
+
* @returns The styled ranges override or null
|
|
325
|
+
*/
|
|
326
|
+
getStyledRangesOverride(formulaId: string): FormulaLatexRanges | null;
|
|
327
|
+
/**
|
|
328
|
+
* Get the LaTeX representation with styling for a formula
|
|
329
|
+
* @param formulaId - The formula ID
|
|
330
|
+
* @returns The LaTeX string with styling
|
|
331
|
+
*/
|
|
332
|
+
getLatexWithStyling(formulaId: string): string;
|
|
333
|
+
/**
|
|
334
|
+
* Get the LaTeX representation without styling for a formula
|
|
335
|
+
* @param formulaId - The formula ID
|
|
336
|
+
* @returns The LaTeX string without styling
|
|
337
|
+
*/
|
|
338
|
+
getLatexWithoutStyling(formulaId: string): string;
|
|
339
|
+
/**
|
|
340
|
+
* Get the styled ranges for a formula
|
|
341
|
+
* @param formulaId - The formula ID
|
|
342
|
+
* @returns The styled ranges (override or computed from formula)
|
|
343
|
+
*/
|
|
344
|
+
getStyledRanges(formulaId: string): FormulaLatexRanges;
|
|
345
|
+
/**
|
|
346
|
+
* Get the align IDs for a formula (for aligned environments)
|
|
347
|
+
* @param formulaId - The formula ID
|
|
348
|
+
* @returns 2D array of IDs or null if not an aligned formula
|
|
349
|
+
*/
|
|
350
|
+
getAlignIds(formulaId: string): string[][] | null;
|
|
351
|
+
/**
|
|
352
|
+
* Get the align column IDs for a formula
|
|
353
|
+
* @param formulaId - The formula ID
|
|
354
|
+
* @returns 2D array of column IDs or null if not an aligned formula
|
|
355
|
+
*/
|
|
356
|
+
getAlignColumnIds(formulaId: string): string[][] | null;
|
|
357
|
+
/**
|
|
358
|
+
* Get the align row internal targets for a formula
|
|
359
|
+
* @param formulaId - The formula ID
|
|
360
|
+
* @returns Array of row targets or null if not an aligned formula
|
|
361
|
+
*/
|
|
362
|
+
getAlignRowInternalTargets(formulaId: string): {
|
|
363
|
+
id: string;
|
|
364
|
+
col: number;
|
|
365
|
+
}[][] | null;
|
|
366
|
+
/**
|
|
367
|
+
* Get the MathML representation for a formula
|
|
368
|
+
* @param formulaId - The formula ID
|
|
369
|
+
* @returns Promise resolving to the MathML string
|
|
370
|
+
*/
|
|
371
|
+
getMathML(formulaId: string): Promise<string>;
|
|
372
|
+
/**
|
|
373
|
+
* Update a formula with a new AugmentedFormula
|
|
374
|
+
* @param formulaId - The formula ID
|
|
375
|
+
* @param newFormula - The new AugmentedFormula
|
|
376
|
+
*/
|
|
377
|
+
updateFormula(formulaId: string, newFormula: AugmentedFormula): void;
|
|
378
|
+
/**
|
|
379
|
+
* Restore formula state from LaTeX string
|
|
380
|
+
* @param formulaId - The formula ID
|
|
381
|
+
* @param latex - The LaTeX string to parse
|
|
382
|
+
*/
|
|
383
|
+
restoreFormulaState(formulaId: string, latex: string): void;
|
|
384
|
+
/**
|
|
385
|
+
* Override the styled ranges for a formula
|
|
386
|
+
* @param formulaId - The formula ID
|
|
387
|
+
* @param styledRanges - The styled ranges to set (or null to clear)
|
|
388
|
+
*/
|
|
389
|
+
overrideStyledRanges(formulaId: string, styledRanges: FormulaLatexRanges | null): void;
|
|
390
|
+
/**
|
|
391
|
+
* Set the suppress editor update flag for a formula
|
|
392
|
+
* @param formulaId - The formula ID
|
|
393
|
+
* @param suppress - Whether to suppress editor updates
|
|
394
|
+
*/
|
|
395
|
+
setSuppressEditorUpdate(formulaId: string, suppress: boolean): void;
|
|
396
|
+
/**
|
|
397
|
+
* Initialize a formula store for a given ID with optional initial LaTeX
|
|
398
|
+
* @param formulaId - The formula ID
|
|
399
|
+
* @param formulaLatex - Optional initial LaTeX string
|
|
400
|
+
*/
|
|
401
|
+
initializeFormula(formulaId: string, formulaLatex?: string): void;
|
|
402
|
+
/**
|
|
403
|
+
* Remove a formula and all its associated state
|
|
404
|
+
* @param formulaId - The formula ID to remove
|
|
405
|
+
*/
|
|
406
|
+
removeFormula(formulaId: string): void;
|
|
407
|
+
/**
|
|
408
|
+
* Check if a formula exists
|
|
409
|
+
* @param formulaId - The formula ID
|
|
410
|
+
* @returns Whether the formula exists
|
|
411
|
+
*/
|
|
412
|
+
hasFormula(formulaId: string): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Update fresh dimensions for a variable (called during variable node creation/update)
|
|
415
|
+
* @param varId - The variable ID
|
|
416
|
+
* @param dimensions - The position and dimensions of the variable element
|
|
417
|
+
*/
|
|
418
|
+
setVariableDimensions(varId: string, dimensions: {
|
|
419
|
+
x: number;
|
|
420
|
+
y: number;
|
|
421
|
+
width: number;
|
|
422
|
+
height: number;
|
|
423
|
+
}): void;
|
|
424
|
+
/**
|
|
425
|
+
* Get fresh dimensions for a variable
|
|
426
|
+
* @param varId - The variable ID
|
|
427
|
+
* @returns The dimensions or undefined if not found
|
|
428
|
+
*/
|
|
429
|
+
getVariableDimensions(varId: string): {
|
|
430
|
+
x: number;
|
|
431
|
+
y: number;
|
|
432
|
+
width: number;
|
|
433
|
+
height: number;
|
|
434
|
+
} | undefined;
|
|
435
|
+
setVariableRolesChanged(value: number): void;
|
|
436
|
+
setFormulas(formulas: IFormula[]): void;
|
|
437
|
+
setEnvironment(environment: IEnvironment): void;
|
|
438
|
+
setValue(id: string, value: number): boolean | undefined;
|
|
439
|
+
setSetValue(id: string, set: (string | number)[]): boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Set a step value directly in the stepValues map.
|
|
442
|
+
* Used by the Controller when applying step state.
|
|
443
|
+
* Does NOT touch the main variables map.
|
|
444
|
+
*/
|
|
445
|
+
setStepValue(id: string, value: IValue): void;
|
|
446
|
+
setDragging(dragging: boolean): void;
|
|
447
|
+
setVariableDrag(varId: string, isDragging: boolean): void;
|
|
448
|
+
setVariableHover(varId: string, isHovered: boolean): void;
|
|
449
|
+
isVariableDragging(varId: string): boolean;
|
|
450
|
+
isVariableHovered(varId: string): boolean;
|
|
451
|
+
isVariableHighlighted(varId: string): boolean;
|
|
452
|
+
get highlightedVarIds(): string[];
|
|
453
|
+
/**
|
|
454
|
+
* Set the mapping between formula IDs and visualization node IDs
|
|
455
|
+
*/
|
|
456
|
+
setFormulaNodeMapping(mapping: Record<string, string>): void;
|
|
457
|
+
/**
|
|
458
|
+
* Set hover state for a visualization node
|
|
459
|
+
* This will trigger the corresponding formula to highlight
|
|
460
|
+
*/
|
|
461
|
+
setNodeHover(nodeId: string, isHovered: boolean): void;
|
|
462
|
+
/**
|
|
463
|
+
* Get hover state for a visualization node
|
|
464
|
+
*/
|
|
465
|
+
getNodeHover(nodeId: string): boolean;
|
|
466
|
+
/**
|
|
467
|
+
* Set hover state for a formula
|
|
468
|
+
* This notifies visualizations that a formula is being hovered
|
|
469
|
+
*/
|
|
470
|
+
setFormulaHover(formulaId: string, isHovered: boolean): void;
|
|
471
|
+
/**
|
|
472
|
+
* Get hover state for a formula
|
|
473
|
+
*/
|
|
474
|
+
getFormulaHover(formulaId: string): boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Subscribe to formula hover changes
|
|
477
|
+
* Returns an unsubscribe function
|
|
478
|
+
*/
|
|
479
|
+
onFormulaHoverChange(callback: (formulaId: string, isHovered: boolean) => void): () => void;
|
|
480
|
+
accessor refreshCallback: (() => void) | null;
|
|
481
|
+
setRefreshCallback(callback: (() => void) | null): void;
|
|
482
|
+
setComputation(): Promise<void>;
|
|
483
|
+
private createEvaluator;
|
|
484
|
+
addVariable(id: string, variableDefinition?: Partial<IVariable>): void;
|
|
485
|
+
setVariableInput(id: string, input: "drag" | "inline" | undefined): void;
|
|
486
|
+
/**
|
|
487
|
+
* Trigger computation by running the manual function.
|
|
488
|
+
* The manual function directly mutates observable variables via proxy.
|
|
489
|
+
*/
|
|
490
|
+
runComputation(): void;
|
|
491
|
+
getDebugState(): {
|
|
492
|
+
variables: {
|
|
493
|
+
id: string;
|
|
494
|
+
value: IValue | undefined;
|
|
495
|
+
input: IInput | undefined;
|
|
496
|
+
}[];
|
|
497
|
+
hasFunction: boolean;
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* Run the semantics function once with current values and collect all step() calls.
|
|
501
|
+
* This follows the reactive data collection pattern similar to sample2DPoint/sample3DPoint.
|
|
502
|
+
* Also stores the dataPointMap for step-dependent point visualization.
|
|
503
|
+
*
|
|
504
|
+
* @returns Array of collected steps from the semantics execution
|
|
505
|
+
*/
|
|
506
|
+
sampleSteps(): ICollectedStep[];
|
|
507
|
+
/**
|
|
508
|
+
* Extract a 2D point from dataPoints map.
|
|
509
|
+
* @param dataPointMap - Map of graph ID to data points
|
|
510
|
+
* @param graphId - The graph ID to look up
|
|
511
|
+
* @returns The first valid {x, y} point or null
|
|
512
|
+
*/
|
|
513
|
+
private extractPoint2D;
|
|
514
|
+
/**
|
|
515
|
+
* Extract a 3D point from dataPoints map.
|
|
516
|
+
* @param dataPoints - Map of graph ID to data points
|
|
517
|
+
* @param graphId - The graph ID to look up
|
|
518
|
+
* @returns The first valid {x, y, z} point or null
|
|
519
|
+
*/
|
|
520
|
+
private extractPoint3D;
|
|
521
|
+
/**
|
|
522
|
+
* Run semantics function with given variables and extract a 2D point.
|
|
523
|
+
* @param variables - Variable values to use
|
|
524
|
+
* @param graphId - Graph ID to match data2d() calls
|
|
525
|
+
* @returns The {x, y} point or null
|
|
526
|
+
*/
|
|
527
|
+
private computeAndExtract2D;
|
|
528
|
+
/**
|
|
529
|
+
* Run semantics function with given variables and extract a 3D point.
|
|
530
|
+
* @param variables - Variable values to use
|
|
531
|
+
* @param graphId - Graph ID to match data3d() calls
|
|
532
|
+
* @returns The {x, y, z} point or null
|
|
533
|
+
*/
|
|
534
|
+
private computeAndExtract3D;
|
|
535
|
+
/**
|
|
536
|
+
* Generic helper to sample the semantic function across a parameter range.
|
|
537
|
+
* Varies a single parameter across its range and collects points using the provided extractor.
|
|
538
|
+
*
|
|
539
|
+
* @param parameter - The variable to vary during sampling
|
|
540
|
+
* @param range - The range to sample [min, max]
|
|
541
|
+
* @param samples - Number of samples
|
|
542
|
+
* @param graphId - Graph ID to match data calls
|
|
543
|
+
* @param extractor - Function to extract point from variables (computeAndExtract2D or computeAndExtract3D)
|
|
544
|
+
* @returns Array of extracted points
|
|
545
|
+
*/
|
|
546
|
+
private sampleWithParameter;
|
|
547
|
+
/**
|
|
548
|
+
* Run the semantic function once with current values to get the current 2D point.
|
|
549
|
+
* Reads x, y values from the dataPoints (from explicit data2d() calls).
|
|
550
|
+
*
|
|
551
|
+
* @param graphId - Graph ID to match data2d() calls
|
|
552
|
+
* @returns The current {x, y} point or null
|
|
553
|
+
*/
|
|
554
|
+
sample2DPoint(graphId: string): {
|
|
555
|
+
x: number;
|
|
556
|
+
y: number;
|
|
557
|
+
} | null;
|
|
558
|
+
/**
|
|
559
|
+
* Run the semantic function once with current values to get the current 3D point.
|
|
560
|
+
* Reads x, y, z values from the dataPoints (from explicit data3d() calls).
|
|
561
|
+
*
|
|
562
|
+
* @param graphId - Graph ID to match graph() calls
|
|
563
|
+
* @returns The current {x, y, z} point or null
|
|
564
|
+
*/
|
|
565
|
+
sample3DPoint(graphId: string): {
|
|
566
|
+
x: number;
|
|
567
|
+
y: number;
|
|
568
|
+
z: number;
|
|
569
|
+
} | null;
|
|
570
|
+
/**
|
|
571
|
+
* Sample the semantic function across a parameter range to collect 2D line data.
|
|
572
|
+
* Reads x, y values from the dataPoints (from explicit data2d() calls).
|
|
573
|
+
*
|
|
574
|
+
* @param parameter - The variable to vary during sampling
|
|
575
|
+
* @param range - The range to sample [min, max]
|
|
576
|
+
* @param samples - Number of samples (default 100)
|
|
577
|
+
* @param graphId - Graph ID to match data2d() calls
|
|
578
|
+
* @returns Array of {x, y} points
|
|
579
|
+
*/
|
|
580
|
+
sample2DLine(parameter: string, range: [number, number], samples: number | undefined, graphId: string): {
|
|
581
|
+
x: number;
|
|
582
|
+
y: number;
|
|
583
|
+
}[];
|
|
584
|
+
/**
|
|
585
|
+
* Sample the semantic function across a parameter range to collect 3D line data.
|
|
586
|
+
* Reads x, y, z values from the dataPoints (from explicit data3d() calls).
|
|
587
|
+
*
|
|
588
|
+
* @param parameter - The variable to vary during sampling
|
|
589
|
+
* @param range - The range to sample [min, max]
|
|
590
|
+
* @param samples - Number of samples (default 100)
|
|
591
|
+
* @param graphId - Graph ID to match graph() calls
|
|
592
|
+
* @returns Array of {x, y, z} points
|
|
593
|
+
*/
|
|
594
|
+
sample3DLine(parameter: string, range: [number, number], samples: number | undefined, graphId: string): {
|
|
595
|
+
x: number;
|
|
596
|
+
y: number;
|
|
597
|
+
z: number;
|
|
598
|
+
}[];
|
|
599
|
+
/**
|
|
600
|
+
* Sample the semantic function across a 2D parameter grid to collect surface data.
|
|
601
|
+
* Reads x, y, z values from the dataPoints (from explicit data3d() calls).
|
|
602
|
+
*
|
|
603
|
+
* @param parameters - The two variables to vary during sampling [param1, param2]
|
|
604
|
+
* @param ranges - The ranges for each parameter [[min1, max1], [min2, max2]]
|
|
605
|
+
* @param samples - Number of samples per dimension (default 50)
|
|
606
|
+
* @param graphId - Graph ID to match graph() calls
|
|
607
|
+
* @returns Array of {x, y, z} points
|
|
608
|
+
*/
|
|
609
|
+
sampleSurface(parameters: [string, string], ranges: [[number, number], [number, number]], samples: number | undefined, graphId: string): {
|
|
610
|
+
x: number;
|
|
611
|
+
y: number;
|
|
612
|
+
z: number;
|
|
613
|
+
}[];
|
|
614
|
+
getVariables(): Record<string, IVariable>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
declare type ContentChange = {
|
|
618
|
+
type: "delete";
|
|
619
|
+
from: number;
|
|
620
|
+
to: number;
|
|
621
|
+
} | {
|
|
622
|
+
type: "insert";
|
|
623
|
+
from: number;
|
|
624
|
+
to: number;
|
|
625
|
+
inserted: string;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Public API - creates a new Formulize instance with its own isolated stores.
|
|
630
|
+
*/
|
|
631
|
+
declare function create(config: FormulizeConfig): Promise<FormulizeInstance>;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Factory function to create a new ComputationStore instance.
|
|
635
|
+
* Used for creating scoped stores per FormulizeProvider.
|
|
636
|
+
*/
|
|
637
|
+
export declare function createComputationStore(): ComputationStore;
|
|
638
|
+
|
|
639
|
+
declare class Delimited extends AugmentedFormulaNodeBase {
|
|
640
|
+
id: string;
|
|
641
|
+
left: string;
|
|
642
|
+
right: string;
|
|
643
|
+
body: AugmentedFormulaNode[];
|
|
644
|
+
type: "delimited";
|
|
645
|
+
constructor(id: string, left: string, right: string, body: AugmentedFormulaNode[]);
|
|
646
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
647
|
+
withChanges({ id, parent, leftSibling, rightSibling, left, right, body, }: {
|
|
648
|
+
id?: string;
|
|
649
|
+
parent?: AugmentedFormulaNode | null;
|
|
650
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
651
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
652
|
+
left?: string;
|
|
653
|
+
right?: string;
|
|
654
|
+
body?: AugmentedFormulaNode[];
|
|
655
|
+
}): Delimited;
|
|
656
|
+
get children(): AugmentedFormulaNode[];
|
|
657
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
declare type DisplayMode = "symbol" | "value" | "both" | "withUnits";
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* EmbeddedFormula - A lightweight formula component for embedding within visualizations.
|
|
664
|
+
*
|
|
665
|
+
* Unlike InlineFormula, this component:
|
|
666
|
+
* - Is designed to be embedded within SVG foreignObject or other visualization contexts
|
|
667
|
+
* - Supports bidirectional hover highlighting with the visualization
|
|
668
|
+
* - Has a more compact default scale
|
|
669
|
+
* - Triggers formula hover events for visualization synchronization
|
|
670
|
+
* - Optionally supports abbreviated display that expands on hover
|
|
671
|
+
*
|
|
672
|
+
* @example Basic usage
|
|
673
|
+
* ```tsx
|
|
674
|
+
* <foreignObject x={100} y={50} width={200} height={50}>
|
|
675
|
+
* <EmbeddedFormula
|
|
676
|
+
* id="formula_z_1_1"
|
|
677
|
+
* highlightOnHover={true}
|
|
678
|
+
* />
|
|
679
|
+
* </foreignObject>
|
|
680
|
+
* ```
|
|
681
|
+
*
|
|
682
|
+
* @example With abbreviation (expands on hover)
|
|
683
|
+
* ```tsx
|
|
684
|
+
* <EmbeddedFormula
|
|
685
|
+
* id="formula_h_1_1"
|
|
686
|
+
* abbreviation="h_1^{(1)}" // Shows this by default
|
|
687
|
+
* // On hover, shows full formula looked up by id
|
|
688
|
+
* />
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
export declare const EmbeddedFormula: default_2.FC<EmbeddedFormulaProps>;
|
|
692
|
+
|
|
693
|
+
declare interface EmbeddedFormulaProps {
|
|
694
|
+
/** Formula ID to render (looks up from environment) */
|
|
695
|
+
id: string;
|
|
696
|
+
/** Optional: Direct LaTeX string (overrides id lookup) */
|
|
697
|
+
latex?: string;
|
|
698
|
+
/**
|
|
699
|
+
* Optional: Abbreviated LaTeX to show by default.
|
|
700
|
+
* If provided, the formula will show this abbreviated version normally,
|
|
701
|
+
* and expand to show the full formula on hover.
|
|
702
|
+
* The full formula is either the `latex` prop or looked up by `id`.
|
|
703
|
+
*/
|
|
704
|
+
abbreviation?: string;
|
|
705
|
+
/** Font scale (default: 0.7 for compact display) */
|
|
706
|
+
scale?: number;
|
|
707
|
+
/** Whether to highlight when formula is hovered via hover system */
|
|
708
|
+
highlightOnHover?: boolean;
|
|
709
|
+
/** Whether clicking can pin the formula open (default: true) */
|
|
710
|
+
allowPinning?: boolean;
|
|
711
|
+
/** Callback when this formula is hovered */
|
|
712
|
+
onHover?: (isHovered: boolean) => void;
|
|
713
|
+
/** Optional class name */
|
|
714
|
+
className?: string;
|
|
715
|
+
/** Optional inline styles */
|
|
716
|
+
style?: default_2.CSSProperties;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
declare type EvaluationFunction = (variables: EvaluationFunctionInput) => Record<string, IValue>;
|
|
720
|
+
|
|
721
|
+
declare type EvaluationFunctionInput = Record<string, number | number[]>;
|
|
722
|
+
|
|
723
|
+
export declare const Formula: default_2.FC<FormulaComponentProps>;
|
|
724
|
+
|
|
725
|
+
declare interface FormulaComponentProps {
|
|
726
|
+
id: string;
|
|
727
|
+
className?: string;
|
|
728
|
+
style?: default_2.CSSProperties;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export declare const FormulaGenerator: {
|
|
732
|
+
/**
|
|
733
|
+
* Generate formulas by iterating over specified ranges.
|
|
734
|
+
*
|
|
735
|
+
* @param spec - Object defining loop variables and their ranges
|
|
736
|
+
* @param generator - Function that generates a formula for each combination
|
|
737
|
+
* @returns Array of formulas
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* // Generate formulas for a 3-layer network with 4 units each
|
|
741
|
+
* Formula.loop({ layer: [1, 3], unit: [1, 4] }, ({ layer, unit }) => ({
|
|
742
|
+
* id: `h_${unit}_${layer}`,
|
|
743
|
+
* latex: `h_{${unit}}^{(${layer})} = \\text{ReLU}(z_{${unit}}^{(${layer})})`,
|
|
744
|
+
* }))
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* // Generate with explicit values
|
|
748
|
+
* Formula.loop({ i: [1, 2, 3, 5, 8] }, ({ i }) => ({
|
|
749
|
+
* id: `fib_${i}`,
|
|
750
|
+
* latex: `F_{${i}}`,
|
|
751
|
+
* }))
|
|
752
|
+
*/
|
|
753
|
+
loop<T extends LoopSpec>(spec: T, generator: (context: LoopContext<T>, index: number) => IFormula): IFormula[];
|
|
754
|
+
/**
|
|
755
|
+
* Generate a single formula with template substitution.
|
|
756
|
+
*
|
|
757
|
+
* @param id - Formula ID (can include ${} placeholders)
|
|
758
|
+
* @param latex - LaTeX string (can include ${} placeholders)
|
|
759
|
+
* @param values - Object of values to substitute
|
|
760
|
+
* @returns A single formula
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* Formula.template("kinetic_${n}", "K_{${n}} = \\frac{1}{2}m_{${n}}v_{${n}}^2", { n: 1 })
|
|
764
|
+
*/
|
|
765
|
+
template(id: string, latex: string, values: Record<string, string | number>): IFormula;
|
|
766
|
+
/**
|
|
767
|
+
* Create a formula directly (identity function for consistency).
|
|
768
|
+
*/
|
|
769
|
+
create(id: string, latex: string): IFormula;
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
declare type FormulaLatexRangeNode = StyledRange | UnstyledRange;
|
|
773
|
+
|
|
774
|
+
declare class FormulaLatexRanges {
|
|
775
|
+
ranges: FormulaLatexRangeNode[];
|
|
776
|
+
constructor(ranges: FormulaLatexRangeNode[]);
|
|
777
|
+
private combineUnstyledRanges;
|
|
778
|
+
getPositionRanges(position: number, includeEdges?: boolean): FormulaLatexRangeNode[];
|
|
779
|
+
toLatex(): string;
|
|
780
|
+
withContentChange(change: ContentChange, activeRanges: Set<string>): FormulaLatexRanges;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export declare const Formulize: {
|
|
784
|
+
create: typeof create;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* User-facing configuration type.
|
|
789
|
+
*/
|
|
790
|
+
export declare type FormulizeConfig = IEnvironment;
|
|
791
|
+
|
|
792
|
+
declare interface FormulizeContextValue {
|
|
793
|
+
instance: FormulizeInstance | null;
|
|
794
|
+
config: FormulizeConfig | null;
|
|
795
|
+
isLoading: boolean;
|
|
796
|
+
error: string | null;
|
|
797
|
+
computationStore: ComputationStore | null;
|
|
798
|
+
/** Reinitialize steps by re-running the semantics function */
|
|
799
|
+
reinitialize: () => void;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Interface for the object returned by Formulize.create()
|
|
804
|
+
*/
|
|
805
|
+
export declare interface FormulizeInstance {
|
|
806
|
+
environment: IEnvironment;
|
|
807
|
+
computationStore: ComputationStore;
|
|
808
|
+
getVariable: (name: string) => IVariable;
|
|
809
|
+
setVariable: (name: string, value: number) => boolean;
|
|
810
|
+
update: (config: FormulizeConfig) => Promise<FormulizeInstance>;
|
|
811
|
+
destroy: () => void;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
export declare const FormulizeProvider: default_2.FC<FormulizeProviderProps>;
|
|
815
|
+
|
|
816
|
+
declare interface FormulizeProviderProps {
|
|
817
|
+
config?: FormulizeConfig;
|
|
818
|
+
children: default_2.ReactNode;
|
|
819
|
+
onError?: (error: string | null) => void;
|
|
820
|
+
onReady?: (instance: FormulizeInstance) => void;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
declare class Fraction extends AugmentedFormulaNodeBase {
|
|
824
|
+
id: string;
|
|
825
|
+
numerator: AugmentedFormulaNode;
|
|
826
|
+
denominator: AugmentedFormulaNode;
|
|
827
|
+
type: "frac";
|
|
828
|
+
constructor(id: string, numerator: AugmentedFormulaNode, denominator: AugmentedFormulaNode);
|
|
829
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
830
|
+
withChanges({ id, parent, leftSibling, rightSibling, numerator, denominator, }: {
|
|
831
|
+
id?: string;
|
|
832
|
+
parent?: AugmentedFormulaNode | null;
|
|
833
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
834
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
835
|
+
numerator?: AugmentedFormulaNode;
|
|
836
|
+
denominator?: AugmentedFormulaNode;
|
|
837
|
+
}): Fraction;
|
|
838
|
+
get children(): AugmentedFormulaNode[];
|
|
839
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export declare const getAllRegistered: () => string[];
|
|
843
|
+
|
|
844
|
+
export declare const getRegistered: (name: string) => React.ComponentType<{
|
|
845
|
+
context: IContext;
|
|
846
|
+
}> | undefined;
|
|
847
|
+
|
|
848
|
+
declare class Group extends AugmentedFormulaNodeBase {
|
|
849
|
+
id: string;
|
|
850
|
+
body: AugmentedFormulaNode[];
|
|
851
|
+
type: "group";
|
|
852
|
+
constructor(id: string, body: AugmentedFormulaNode[]);
|
|
853
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
854
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, }: {
|
|
855
|
+
id?: string;
|
|
856
|
+
parent?: AugmentedFormulaNode | null;
|
|
857
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
858
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
859
|
+
body?: AugmentedFormulaNode[];
|
|
860
|
+
}): Group;
|
|
861
|
+
get children(): AugmentedFormulaNode[];
|
|
862
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export declare type I2DConfig = I2DLine | I2DPoint;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Base configuration for graph-based 2D visualizations.
|
|
869
|
+
* Uses explicit data2d() calls in manual functions to collect coordinates.
|
|
870
|
+
* @property: id - Graph ID to match data2d() calls in manual function (required)
|
|
871
|
+
* @property: name - Display name for the legend
|
|
872
|
+
* @property: showInLegend - Whether to show in legend
|
|
873
|
+
*/
|
|
874
|
+
declare interface I2DConfigBase {
|
|
875
|
+
id: string;
|
|
876
|
+
name?: string;
|
|
877
|
+
showInLegend?: boolean;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Line graph: samples over a parameter variable to create a 2D line/curve.
|
|
882
|
+
* The manual function must call data2d(id, {x, y}) to provide coordinates.
|
|
883
|
+
* @property: type - The type of object to graph
|
|
884
|
+
* @property: parameter - The variable to vary during sampling (1 parameter for lines)
|
|
885
|
+
* @property: range - Optional range to sample over the parameter (defaults to the variable's range)
|
|
886
|
+
* @property: samples - Number of samples (default 100)
|
|
887
|
+
* @property: color - Line color
|
|
888
|
+
* @property: lineWidth - Line width
|
|
889
|
+
* @property: interaction - Drag interaction: ["horizontal-drag" | "vertical-drag", variableName]
|
|
890
|
+
*/
|
|
891
|
+
export declare interface I2DLine extends I2DConfigBase {
|
|
892
|
+
type: "line";
|
|
893
|
+
parameter: string;
|
|
894
|
+
range?: [number, number];
|
|
895
|
+
samples?: number;
|
|
896
|
+
color?: string;
|
|
897
|
+
lineWidth?: number;
|
|
898
|
+
interaction?: ["horizontal-drag" | "vertical-drag", string];
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Point graph: shows the current point without sampling (0 parameters).
|
|
903
|
+
* The manual function must call data2d(id, {x, y}) to provide coordinates.
|
|
904
|
+
* @property type - The type of object to graph
|
|
905
|
+
* @property color - Marker color
|
|
906
|
+
* @property size - Marker size
|
|
907
|
+
* @property showLabel - Whether to show label
|
|
908
|
+
* @property interaction - Drag interaction: ["horizontal-drag" | "vertical-drag", variableName]
|
|
909
|
+
* @property stepId - Optional step ID that controls when this point appears during stepping.
|
|
910
|
+
* When set, the point only appears after the step() call with matching id has been reached.
|
|
911
|
+
* @property persistence - Controls point visibility during stepping (default: true):
|
|
912
|
+
* true = point stays visible after its step (accumulate)
|
|
913
|
+
* false = point only visible at that exact step
|
|
914
|
+
*/
|
|
915
|
+
export declare interface I2DPoint extends I2DConfigBase {
|
|
916
|
+
type: "point";
|
|
917
|
+
color?: string;
|
|
918
|
+
size?: number;
|
|
919
|
+
showLabel?: boolean;
|
|
920
|
+
interaction?: ["horizontal-drag" | "vertical-drag", string];
|
|
921
|
+
stepId?: string;
|
|
922
|
+
persistence?: boolean;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Line graph: samples over 1 parameter to create a 3D line
|
|
927
|
+
* @property: type - The type of object to graph
|
|
928
|
+
* @property: parameter - The variable to vary during sampling (1 parameter for lines)
|
|
929
|
+
* @property: range - Optional range to sample over the parameter (defaults to the variable's range)
|
|
930
|
+
* @property: samples - Number of samples (default 100)
|
|
931
|
+
* @property: color - Line color
|
|
932
|
+
* @property: width - Line width
|
|
933
|
+
*/
|
|
934
|
+
declare interface I3DLine extends IGraphBase {
|
|
935
|
+
type: "line";
|
|
936
|
+
parameter: string;
|
|
937
|
+
range?: [number, number];
|
|
938
|
+
samples?: number;
|
|
939
|
+
color?: string;
|
|
940
|
+
width?: number;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Point graph: shows the current point without sampling
|
|
945
|
+
* @property: type - The type of object to graph
|
|
946
|
+
* @property: color - Marker color
|
|
947
|
+
* @property: size - Marker size
|
|
948
|
+
*/
|
|
949
|
+
declare interface I3DPoint extends IGraphBase {
|
|
950
|
+
type: "point";
|
|
951
|
+
color?: string;
|
|
952
|
+
size?: number;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Surface graph: samples over 2 parameters to create a 3D surface
|
|
957
|
+
* @property: type - The type of object to graph
|
|
958
|
+
* @property: parameters - The variables to vary during sampling (2 parameters for surfaces)
|
|
959
|
+
* @property: ranges - Optional ranges to sample over the parameters (defaults to the variables' ranges)
|
|
960
|
+
* @property: samples - Number of samples for each parameter (default 50)
|
|
961
|
+
* @property: color - Surface color or colorscale
|
|
962
|
+
* @property: opacity - Surface opacity (0-1)
|
|
963
|
+
* @property: showColorbar - Whether to show colorbar
|
|
964
|
+
*/
|
|
965
|
+
declare interface I3DSurface extends IGraphBase {
|
|
966
|
+
type: "surface";
|
|
967
|
+
parameters: [string, string];
|
|
968
|
+
ranges?: [[number, number], [number, number]];
|
|
969
|
+
samples?: number;
|
|
970
|
+
color?: string | string[];
|
|
971
|
+
opacity?: number;
|
|
972
|
+
showColorbar?: boolean;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
declare interface IButtonControl extends IControl {
|
|
976
|
+
type: "button";
|
|
977
|
+
code?: (variables: Record<string, any>) => void;
|
|
978
|
+
label?: string;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
declare interface ICheckboxControl extends IControl {
|
|
982
|
+
type: "checkbox";
|
|
983
|
+
availableElements: string[];
|
|
984
|
+
orientation?: "horizontal" | "vertical";
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* A collected step from reactive data collection during semantics execution.
|
|
989
|
+
* Used by the new reactive step system (similar to plot2d/plot3d pattern).
|
|
990
|
+
* @property index - Execution order (0, 1, 2...)
|
|
991
|
+
* @property id - Optional step identifier (from second parameter of step() call)
|
|
992
|
+
* @property description - The description text to display
|
|
993
|
+
* @property values - Array of [varId, value] tuples mapping variable IDs to runtime values
|
|
994
|
+
* @property expression - Optional expression scope for bounding box highlighting
|
|
995
|
+
* @property formulas - Optional per-formula views for multi-formula steps
|
|
996
|
+
*/
|
|
997
|
+
export declare interface ICollectedStep {
|
|
998
|
+
index: number;
|
|
999
|
+
id?: string;
|
|
1000
|
+
description: string;
|
|
1001
|
+
values?: Array<[string, IValue]>;
|
|
1002
|
+
expression?: string;
|
|
1003
|
+
formulas?: Record<string, IView>;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export declare interface IContext {
|
|
1007
|
+
variables: Record<string, number>;
|
|
1008
|
+
updateVariable: (variableName: string, value: number) => void;
|
|
1009
|
+
getVariable: (variableName: string) => number;
|
|
1010
|
+
/** Set hover state for a visualization node (triggers formula highlighting) */
|
|
1011
|
+
setNodeHover?: (nodeId: string, isHovered: boolean) => void;
|
|
1012
|
+
/** Get current hover state for a node */
|
|
1013
|
+
getNodeHover?: (nodeId: string) => boolean;
|
|
1014
|
+
/** Set hover state for a formula (for visualization to react to) */
|
|
1015
|
+
setFormulaHover?: (formulaId: string, isHovered: boolean) => void;
|
|
1016
|
+
/** Get current hover state for a formula */
|
|
1017
|
+
getFormulaHover?: (formulaId: string) => boolean;
|
|
1018
|
+
/** Subscribe to formula hover changes */
|
|
1019
|
+
onFormulaHoverChange?: (callback: (formulaId: string, isHovered: boolean) => void) => () => void;
|
|
1020
|
+
/** Custom configuration from the visualization config */
|
|
1021
|
+
config?: Record<string, unknown>;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
declare interface IControl {
|
|
1025
|
+
id?: string;
|
|
1026
|
+
type: "slider" | "dropdown" | "checkbox" | "button" | "radio" | "set";
|
|
1027
|
+
variable?: string;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
export declare type IControls = ISliderControl | IDropdownControl | ICheckboxControl | IButtonControl | IRadioControl | ISetControl;
|
|
1031
|
+
|
|
1032
|
+
export declare interface ICustom {
|
|
1033
|
+
type: "custom";
|
|
1034
|
+
id?: string;
|
|
1035
|
+
variables: string[];
|
|
1036
|
+
component?: string;
|
|
1037
|
+
styles?: Record<string, string>;
|
|
1038
|
+
update?: {
|
|
1039
|
+
onVariableChange?: boolean;
|
|
1040
|
+
};
|
|
1041
|
+
/** Custom configuration passed to the component */
|
|
1042
|
+
config?: Record<string, unknown>;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* 2D coordinate values for data2d() calls.
|
|
1047
|
+
* @property {number} x - X coordinate value
|
|
1048
|
+
* @property {number} y - Y coordinate value
|
|
1049
|
+
*/
|
|
1050
|
+
declare interface IData2D {
|
|
1051
|
+
x: number;
|
|
1052
|
+
y: number;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Function to store 2D data points for visualization.
|
|
1057
|
+
* @param id - Unique identifier for the graph/visualization
|
|
1058
|
+
* @param values - Explicit coordinate values {x, y}
|
|
1059
|
+
* @example data2d("curve", {x: vars.x, y: vars.y})
|
|
1060
|
+
*/
|
|
1061
|
+
declare type IData2DFn = (id: string, values: IData2D) => void;
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* 3D coordinate values for data3d() calls.
|
|
1065
|
+
* @property {number} x - X coordinate value
|
|
1066
|
+
* @property {number} y - Y coordinate value
|
|
1067
|
+
* @property {number} z - Z coordinate value
|
|
1068
|
+
*/
|
|
1069
|
+
declare interface IData3D {
|
|
1070
|
+
x: number;
|
|
1071
|
+
y: number;
|
|
1072
|
+
z: number;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Function to store 3D data points for visualization.
|
|
1077
|
+
* @param id - Unique identifier for the graph/visualization
|
|
1078
|
+
* @param values - Explicit coordinate values {x, y, z}
|
|
1079
|
+
* @example data3d("surface", {x: vars.x, y: vars.y, z: vars.z})
|
|
1080
|
+
*/
|
|
1081
|
+
declare type IData3DFn = (id: string, values: IData3D) => void;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Types for data2d() and data3d() functions used in manual computation.
|
|
1085
|
+
* Allows imperative collection of visualization data points.
|
|
1086
|
+
*/
|
|
1087
|
+
/**
|
|
1088
|
+
* A snapshot of coordinate values at the time of a data2d/data3d call.
|
|
1089
|
+
*/
|
|
1090
|
+
declare type IDataPoint = Record<string, number>;
|
|
1091
|
+
|
|
1092
|
+
declare interface IDropdownControl extends IControl {
|
|
1093
|
+
type: "dropdown";
|
|
1094
|
+
options: Array<{
|
|
1095
|
+
value: string;
|
|
1096
|
+
label: string;
|
|
1097
|
+
}>;
|
|
1098
|
+
placeholder?: string;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export declare interface IEnvironment {
|
|
1102
|
+
formulas: IFormula[];
|
|
1103
|
+
variables: IVariablesUserInput;
|
|
1104
|
+
semantics?: ISemantics;
|
|
1105
|
+
visualizations?: IVisualization[];
|
|
1106
|
+
controls?: IControls[];
|
|
1107
|
+
stepping?: boolean;
|
|
1108
|
+
fontSize?: number;
|
|
1109
|
+
labelFontSize?: number;
|
|
1110
|
+
labelNodeStyle?: React.CSSProperties;
|
|
1111
|
+
formulaNodeStyle?: React.CSSProperties;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
export declare interface IFormula {
|
|
1115
|
+
id: string;
|
|
1116
|
+
latex: string;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
declare type IGraph = I3DLine | I3DSurface | I3DPoint;
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Base configuration for graph-based visualizations.
|
|
1123
|
+
* All graphs read x, y, z values from explicit graph() calls: graph("id", {x, y, z})
|
|
1124
|
+
* @property: id - Graph ID to match graph() calls in manual function. Required to link this visualization to the corresponding graph() call.
|
|
1125
|
+
* @property: name - Display name for the legend
|
|
1126
|
+
* @property: showInLegend - Whether to show in legend
|
|
1127
|
+
*/
|
|
1128
|
+
declare interface IGraphBase {
|
|
1129
|
+
id: string;
|
|
1130
|
+
name?: string;
|
|
1131
|
+
showInLegend?: boolean;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* The input type for a variable.
|
|
1136
|
+
* - "drag" variables allow users to drag/slide to change the value.
|
|
1137
|
+
* - "inline" variables display an editable text input for direct value entry.
|
|
1138
|
+
* Variables without input are either constants or computed by the manual function.
|
|
1139
|
+
*/
|
|
1140
|
+
declare type IInput = "drag" | "inline";
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* InlineFormula - Renders a formula inline within text
|
|
1144
|
+
*
|
|
1145
|
+
* Usage:
|
|
1146
|
+
* ```tsx
|
|
1147
|
+
* <FormulizeProvider config={config}>
|
|
1148
|
+
* <p>The formula <InlineFormula id="kinetic-energy" /> shows energy.</p>
|
|
1149
|
+
* </FormulizeProvider>
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
export declare const InlineFormula: default_2.FC<InlineFormulaProps>;
|
|
1153
|
+
|
|
1154
|
+
declare interface InlineFormulaProps {
|
|
1155
|
+
/** Formula ID to render (looks up from environment) */
|
|
1156
|
+
id: string;
|
|
1157
|
+
/** Optional class name */
|
|
1158
|
+
className?: string;
|
|
1159
|
+
/** Optional inline styles */
|
|
1160
|
+
style?: default_2.CSSProperties;
|
|
1161
|
+
/** Font scale relative to surrounding text (default: 1) */
|
|
1162
|
+
scale?: number;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* InlineVariable - Renders a variable inline within text
|
|
1167
|
+
*
|
|
1168
|
+
* Usage:
|
|
1169
|
+
* ```tsx
|
|
1170
|
+
* <FormulizeProvider config={config}>
|
|
1171
|
+
* <p>The mass <InlineVariable id="m" display="withUnits" /> affects energy.</p>
|
|
1172
|
+
* </FormulizeProvider>
|
|
1173
|
+
* ```
|
|
1174
|
+
*/
|
|
1175
|
+
export declare const InlineVariable: default_2.FC<InlineVariableProps>;
|
|
1176
|
+
|
|
1177
|
+
declare interface InlineVariableProps {
|
|
1178
|
+
/** Variable ID to render */
|
|
1179
|
+
id: string;
|
|
1180
|
+
/** Display mode: "symbol" (m), "value" (2), "both" (m = 2), "withUnits" (2 kg) */
|
|
1181
|
+
display?: DisplayMode;
|
|
1182
|
+
/** Optional class name */
|
|
1183
|
+
className?: string;
|
|
1184
|
+
/** Optional inline styles */
|
|
1185
|
+
style?: default_2.CSSProperties;
|
|
1186
|
+
/** Font scale relative to surrounding text (default: 1) */
|
|
1187
|
+
scale?: number;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* Plot2D visualization configuration.
|
|
1192
|
+
* @property type - The type of the plot.
|
|
1193
|
+
* @property id - The id of the plot.
|
|
1194
|
+
* @property title - The title of the plot.
|
|
1195
|
+
* @property xAxisLabel - The label for the x-axis (cosmetic only, does not affect graphing).
|
|
1196
|
+
* @property xAxisVar - The variable to bind to x-axis for hover highlighting (optional)
|
|
1197
|
+
* @property xRange - The range of the x-axis.
|
|
1198
|
+
* @property xAxisInterval - The interval of the x-axis.
|
|
1199
|
+
* @property xAxisPos - The position of the x-axis. "center" = x-axis at y=0, "edge" = x-axis at bottom
|
|
1200
|
+
* @property xGrid - The grid visibility for the x-axis.
|
|
1201
|
+
* @property yAxisLabel - The label for the y-axis (cosmetic only, does not affect graphing).
|
|
1202
|
+
* @property yAxisVar - The variable to bind to y-axis for hover highlighting (optional)
|
|
1203
|
+
* @property yRange - The range of the y-axis.
|
|
1204
|
+
* @property yAxisInterval - The interval of the y-axis.
|
|
1205
|
+
* @property yAxisPos - The position of the y-axis.
|
|
1206
|
+
* @property yGrid - The grid visibility for the y-axis.
|
|
1207
|
+
* @property vectors - The vectors for the plot.
|
|
1208
|
+
* @property graphs - Graph-based visualizations using data collected by data2d() calls.
|
|
1209
|
+
* Points with stepId will only appear during stepping when that step is reached.
|
|
1210
|
+
* @property width - The width of the plot.
|
|
1211
|
+
* @property height - The height of the plot.
|
|
1212
|
+
* @property tickFontSize - The font size of the ticks.
|
|
1213
|
+
* @property interaction - The interaction of the plot.
|
|
1214
|
+
*/
|
|
1215
|
+
export declare interface IPlot2D {
|
|
1216
|
+
type: "plot2d";
|
|
1217
|
+
id?: string;
|
|
1218
|
+
title?: string;
|
|
1219
|
+
xAxisLabel?: string;
|
|
1220
|
+
xAxisVar?: string;
|
|
1221
|
+
xRange?: [number, number];
|
|
1222
|
+
xAxisInterval?: number;
|
|
1223
|
+
xAxisPos?: "center" | "edge";
|
|
1224
|
+
xLabelPos?: "center" | "right";
|
|
1225
|
+
xGrid?: "show" | "hide";
|
|
1226
|
+
yAxisLabel?: string;
|
|
1227
|
+
yAxisVar?: string;
|
|
1228
|
+
yRange?: [number, number];
|
|
1229
|
+
yAxisInterval?: number;
|
|
1230
|
+
yAxisPos?: "center" | "edge";
|
|
1231
|
+
yLabelPos?: "center" | "top";
|
|
1232
|
+
yGrid?: "show" | "hide";
|
|
1233
|
+
vectors?: IVector[];
|
|
1234
|
+
graphs?: I2DConfig[];
|
|
1235
|
+
width?: number | string;
|
|
1236
|
+
height?: number | string;
|
|
1237
|
+
tickFontSize?: number;
|
|
1238
|
+
interaction?: ["horizontal-drag" | "vertical-drag", string];
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export declare interface IPlot3D {
|
|
1242
|
+
type: "plot3d";
|
|
1243
|
+
id?: string;
|
|
1244
|
+
title?: string;
|
|
1245
|
+
xAxis?: string;
|
|
1246
|
+
xRange?: [number, number];
|
|
1247
|
+
yAxis?: string;
|
|
1248
|
+
yRange?: [number, number];
|
|
1249
|
+
zVar?: string;
|
|
1250
|
+
zRange?: [number, number];
|
|
1251
|
+
width?: number | string;
|
|
1252
|
+
height?: number | string;
|
|
1253
|
+
plotType?: "scatter" | "surface" | "line" | "mesh";
|
|
1254
|
+
showCurrentPointInLegend?: boolean;
|
|
1255
|
+
/**
|
|
1256
|
+
* Graph-based visualizations using data collected by graph() calls in manual functions.
|
|
1257
|
+
* The visualization will sample the manual function and render the collected graph data.
|
|
1258
|
+
*/
|
|
1259
|
+
graphs?: IGraph[];
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
declare interface IRadioControl extends IControl {
|
|
1263
|
+
type: "radio";
|
|
1264
|
+
orientation?: "horizontal" | "vertical";
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Semantics function type.
|
|
1269
|
+
* Receives a context object with variable values and data collection functions.
|
|
1270
|
+
* Users can destructure only what they need: ({ vars, data2d }) => { ... }
|
|
1271
|
+
*/
|
|
1272
|
+
export declare type ISemantics = (ctx: ISemanticsContext) => void;
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Context object passed to semantics functions.
|
|
1276
|
+
* Users can destructure only the properties they need.
|
|
1277
|
+
* @property vars - Proxy object for reading/writing variable values
|
|
1278
|
+
* @property data2d - Function to collect 2D visualization data points: data2d("id", {x, y})
|
|
1279
|
+
* @property data3d - Function to collect 3D visualization data points: data3d("id", {x, y, z})
|
|
1280
|
+
* @property step - Function for step-through debugging breakpoints
|
|
1281
|
+
*/
|
|
1282
|
+
export declare interface ISemanticsContext {
|
|
1283
|
+
vars: Record<string, any>;
|
|
1284
|
+
data2d: IData2DFn;
|
|
1285
|
+
data3d: IData3DFn;
|
|
1286
|
+
step: IStepFn;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
declare interface ISetControl extends IControl {
|
|
1290
|
+
type: "set";
|
|
1291
|
+
availableElements: string[];
|
|
1292
|
+
color?: string;
|
|
1293
|
+
maxHeight?: number;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
declare interface ISliderControl extends IControl {
|
|
1297
|
+
type: "slider";
|
|
1298
|
+
orientation?: "horizontal" | "vertical";
|
|
1299
|
+
showValue?: boolean;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
export declare const isRegistered: (name: string) => boolean;
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Step function type for step-through debugging.
|
|
1306
|
+
*/
|
|
1307
|
+
declare type IStepFn = (config: any, blockId?: string) => void;
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Step input: either a single view (applies to all formulas) or multiple views keyed by formulaId
|
|
1311
|
+
* - Single: { description: "...", values: [...], expression: "..." }
|
|
1312
|
+
* - Multi-formula: { "formula-id": { description: "...", ... }, "other-id": { ... } }
|
|
1313
|
+
*/
|
|
1314
|
+
export declare type IStepInput = IView | Record<string, IView>;
|
|
1315
|
+
|
|
1316
|
+
export declare type IValue = number | (string | number)[];
|
|
1317
|
+
|
|
1318
|
+
export declare interface IVariable {
|
|
1319
|
+
value?: IValue;
|
|
1320
|
+
dataType?: "scalar" | "vector" | "matrix" | "set";
|
|
1321
|
+
dimensions?: number[];
|
|
1322
|
+
units?: string;
|
|
1323
|
+
name?: string;
|
|
1324
|
+
precision?: number;
|
|
1325
|
+
description?: string;
|
|
1326
|
+
range?: [number, number];
|
|
1327
|
+
step?: number;
|
|
1328
|
+
options?: string[];
|
|
1329
|
+
key?: string;
|
|
1330
|
+
latexDisplay?: "name" | "value";
|
|
1331
|
+
labelDisplay?: "name" | "value" | "svg" | "none";
|
|
1332
|
+
svgPath?: string;
|
|
1333
|
+
svgContent?: VariableSVGContent;
|
|
1334
|
+
svgSize?: {
|
|
1335
|
+
width: number;
|
|
1336
|
+
height: number;
|
|
1337
|
+
};
|
|
1338
|
+
svgMode?: "replace" | "append";
|
|
1339
|
+
defaultCSS?: string;
|
|
1340
|
+
hoverCSS?: string;
|
|
1341
|
+
input?: IInput;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Variable input format. Users can specify variables as:
|
|
1346
|
+
* - A number: `a: 0.1` (becomes a constant with that value)
|
|
1347
|
+
* - An IVariable object: `W: { input: "drag" }` (for interactive variables)
|
|
1348
|
+
*/
|
|
1349
|
+
export declare type IVariableInput = number | IVariable;
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* User-facing variables config (for environment).
|
|
1353
|
+
* Uses "default" instead of "value" for better clarity in user-facing API.
|
|
1354
|
+
*/
|
|
1355
|
+
export declare type IVariablesUserInput = Record<string, number | IVariableUserInput>;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* User-facing variable definition that uses "default" instead of "value"
|
|
1359
|
+
*/
|
|
1360
|
+
export declare type IVariableUserInput = Omit<IVariable, "value"> & {
|
|
1361
|
+
default?: IValue;
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
declare interface IVector {
|
|
1365
|
+
x: (string | number)[];
|
|
1366
|
+
y: (string | number)[];
|
|
1367
|
+
shape?: "arrow" | "dash" | "point";
|
|
1368
|
+
color?: string;
|
|
1369
|
+
lineWidth?: number;
|
|
1370
|
+
markerSize?: number;
|
|
1371
|
+
name?: string;
|
|
1372
|
+
draggable?: boolean;
|
|
1373
|
+
showlegend?: boolean;
|
|
1374
|
+
label?: string;
|
|
1375
|
+
labelPosition?: "start" | "mid" | "end";
|
|
1376
|
+
labelOffsetX?: number;
|
|
1377
|
+
labelOffsetY?: number;
|
|
1378
|
+
labelColor?: string;
|
|
1379
|
+
labelFontSize?: number;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* A single formula's view data
|
|
1384
|
+
* @property description - The description text to display
|
|
1385
|
+
* @property values - Array of [varId, value] tuples mapping LaTeX variable IDs to runtime values
|
|
1386
|
+
* @property expression - Optional expression scope for bounding box highlighting
|
|
1387
|
+
*/
|
|
1388
|
+
export declare interface IView {
|
|
1389
|
+
description: string;
|
|
1390
|
+
values?: Array<[string, IValue]>;
|
|
1391
|
+
expression?: string;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
export declare type IVisualization = IPlot2D | IPlot3D | ICustom;
|
|
1395
|
+
|
|
1396
|
+
declare type LatexMode = "render" | "no-id" | "content-only";
|
|
1397
|
+
|
|
1398
|
+
declare type LatexRange = [string, {
|
|
1399
|
+
[id: string]: [number, number];
|
|
1400
|
+
}];
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Context passed to generator callbacks.
|
|
1404
|
+
* Contains the current iteration values for each loop variable.
|
|
1405
|
+
*/
|
|
1406
|
+
export declare type LoopContext<T extends LoopSpec> = {
|
|
1407
|
+
[K in keyof T]: number;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Range specification for loop iterations.
|
|
1412
|
+
* Can be:
|
|
1413
|
+
* - A number: [1, n] inclusive
|
|
1414
|
+
* - A tuple [start, end]: inclusive range
|
|
1415
|
+
* - An array of specific values
|
|
1416
|
+
*/
|
|
1417
|
+
export declare type LoopRange = number | [number, number] | number[];
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Specification for loop iteration bounds.
|
|
1421
|
+
* Keys are variable names, values define the iteration range.
|
|
1422
|
+
*/
|
|
1423
|
+
export declare type LoopSpec = Record<string, LoopRange>;
|
|
1424
|
+
|
|
1425
|
+
declare class MathSymbol extends AugmentedFormulaNodeBase {
|
|
1426
|
+
id: string;
|
|
1427
|
+
value: string;
|
|
1428
|
+
type: "symbol";
|
|
1429
|
+
constructor(id: string, value: string);
|
|
1430
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1431
|
+
withChanges({ id, parent, leftSibling, rightSibling, value, }: {
|
|
1432
|
+
id?: string;
|
|
1433
|
+
parent?: AugmentedFormulaNode | null;
|
|
1434
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1435
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1436
|
+
value?: string;
|
|
1437
|
+
}): MathSymbol;
|
|
1438
|
+
get children(): AugmentedFormulaNode[];
|
|
1439
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
declare class Matrix extends AugmentedFormulaNodeBase {
|
|
1443
|
+
id: string;
|
|
1444
|
+
matrixType: "bmatrix" | "pmatrix" | "vmatrix" | "Vmatrix" | "matrix";
|
|
1445
|
+
body: AugmentedFormulaNode[][];
|
|
1446
|
+
type: "matrix";
|
|
1447
|
+
constructor(id: string, matrixType: "bmatrix" | "pmatrix" | "vmatrix" | "Vmatrix" | "matrix", body: AugmentedFormulaNode[][]);
|
|
1448
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1449
|
+
withChanges({ id, parent, leftSibling, rightSibling, matrixType, body, }: {
|
|
1450
|
+
id?: string;
|
|
1451
|
+
parent?: AugmentedFormulaNode | null;
|
|
1452
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1453
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1454
|
+
matrixType?: "bmatrix" | "pmatrix" | "vmatrix" | "Vmatrix" | "matrix";
|
|
1455
|
+
body?: AugmentedFormulaNode[][];
|
|
1456
|
+
}): Matrix;
|
|
1457
|
+
get children(): AugmentedFormulaNode[];
|
|
1458
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Merge multiple formula arrays into one.
|
|
1463
|
+
*/
|
|
1464
|
+
export declare function mergeFormulas(...sources: IFormula[][]): IFormula[];
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* Merge multiple variable objects into one.
|
|
1468
|
+
* Later objects override earlier ones for duplicate keys.
|
|
1469
|
+
*/
|
|
1470
|
+
export declare function mergeVariables(...sources: IVariablesUserInput[]): IVariablesUserInput;
|
|
1471
|
+
|
|
1472
|
+
declare class Op extends AugmentedFormulaNodeBase {
|
|
1473
|
+
id: string;
|
|
1474
|
+
operator: string;
|
|
1475
|
+
limits: boolean;
|
|
1476
|
+
type: "op";
|
|
1477
|
+
constructor(id: string, operator: string, limits: boolean);
|
|
1478
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1479
|
+
withChanges({ id, parent, leftSibling, rightSibling, operator, limits, }: {
|
|
1480
|
+
id?: string;
|
|
1481
|
+
parent?: AugmentedFormulaNode | null;
|
|
1482
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1483
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1484
|
+
operator?: string;
|
|
1485
|
+
limits?: boolean;
|
|
1486
|
+
body?: AugmentedFormulaNode;
|
|
1487
|
+
}): Op;
|
|
1488
|
+
get children(): AugmentedFormulaNode[];
|
|
1489
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
declare type RangeElement = string | LatexRange;
|
|
1493
|
+
|
|
1494
|
+
export declare const register: (name: string, component: React.ComponentType<{
|
|
1495
|
+
context: IContext;
|
|
1496
|
+
}>) => void;
|
|
1497
|
+
|
|
1498
|
+
export declare function registerBuiltInComponents(): void;
|
|
1499
|
+
|
|
1500
|
+
declare type RenderSpec = {
|
|
1501
|
+
tagName: string;
|
|
1502
|
+
id?: string;
|
|
1503
|
+
className?: string;
|
|
1504
|
+
style?: Record<string, string>;
|
|
1505
|
+
attrs: Record<string, string>;
|
|
1506
|
+
children: RenderSpec[];
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
declare class Root extends AugmentedFormulaNodeBase {
|
|
1510
|
+
id: string;
|
|
1511
|
+
body: AugmentedFormulaNode;
|
|
1512
|
+
index?: AugmentedFormulaNode | undefined;
|
|
1513
|
+
type: "root";
|
|
1514
|
+
constructor(id: string, body: AugmentedFormulaNode, index?: AugmentedFormulaNode | undefined);
|
|
1515
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1516
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, index, }: {
|
|
1517
|
+
id?: string;
|
|
1518
|
+
parent?: AugmentedFormulaNode | null;
|
|
1519
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1520
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1521
|
+
body?: AugmentedFormulaNode;
|
|
1522
|
+
index?: AugmentedFormulaNode;
|
|
1523
|
+
}): Root;
|
|
1524
|
+
get children(): AugmentedFormulaNode[];
|
|
1525
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
declare class Script extends AugmentedFormulaNodeBase {
|
|
1529
|
+
id: string;
|
|
1530
|
+
base: AugmentedFormulaNode;
|
|
1531
|
+
sub?: AugmentedFormulaNode | undefined;
|
|
1532
|
+
sup?: AugmentedFormulaNode | undefined;
|
|
1533
|
+
type: "script";
|
|
1534
|
+
constructor(id: string, base: AugmentedFormulaNode, sub?: AugmentedFormulaNode | undefined, sup?: AugmentedFormulaNode | undefined);
|
|
1535
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1536
|
+
withChanges({ id, parent, leftSibling, rightSibling, base, sub, sup, }: {
|
|
1537
|
+
id?: string;
|
|
1538
|
+
parent?: AugmentedFormulaNode | null;
|
|
1539
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1540
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1541
|
+
base?: AugmentedFormulaNode;
|
|
1542
|
+
sub?: AugmentedFormulaNode;
|
|
1543
|
+
sup?: AugmentedFormulaNode;
|
|
1544
|
+
}): Script;
|
|
1545
|
+
get children(): AugmentedFormulaNode[];
|
|
1546
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
declare class Space extends AugmentedFormulaNodeBase {
|
|
1550
|
+
id: string;
|
|
1551
|
+
text: string;
|
|
1552
|
+
type: "space";
|
|
1553
|
+
constructor(id: string, text: string);
|
|
1554
|
+
toLatex(_: LatexMode, offset: number): LatexRange;
|
|
1555
|
+
withChanges({ id, parent, leftSibling, rightSibling, text, }: {
|
|
1556
|
+
id?: string;
|
|
1557
|
+
parent?: AugmentedFormulaNode | null;
|
|
1558
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1559
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1560
|
+
text?: string;
|
|
1561
|
+
}): Space;
|
|
1562
|
+
get children(): AugmentedFormulaNode[];
|
|
1563
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* A step control component for navigating through collected steps.
|
|
1568
|
+
* Uses the new reactive step system. Must be used inside a FormulizeProvider.
|
|
1569
|
+
*/
|
|
1570
|
+
export declare const StepControl: default_2.FC<StepControlProps>;
|
|
1571
|
+
|
|
1572
|
+
export declare interface StepControlProps {
|
|
1573
|
+
/** Optional className for additional styling */
|
|
1574
|
+
className?: string;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
declare class Strikethrough extends AugmentedFormulaNodeBase {
|
|
1578
|
+
id: string;
|
|
1579
|
+
body: AugmentedFormulaNode;
|
|
1580
|
+
type: "strikethrough";
|
|
1581
|
+
constructor(id: string, body: AugmentedFormulaNode);
|
|
1582
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1583
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, }: {
|
|
1584
|
+
id?: string;
|
|
1585
|
+
parent?: AugmentedFormulaNode | null;
|
|
1586
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1587
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1588
|
+
body?: AugmentedFormulaNode;
|
|
1589
|
+
}): Strikethrough;
|
|
1590
|
+
get children(): AugmentedFormulaNode[];
|
|
1591
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
declare class StyledRange {
|
|
1595
|
+
id: string;
|
|
1596
|
+
left: string;
|
|
1597
|
+
children: FormulaLatexRangeNode[];
|
|
1598
|
+
right: string;
|
|
1599
|
+
hints?: {
|
|
1600
|
+
color?: string;
|
|
1601
|
+
tooltip?: string;
|
|
1602
|
+
noMark?: boolean;
|
|
1603
|
+
} | undefined;
|
|
1604
|
+
constructor(id: string, left: string, children: FormulaLatexRangeNode[], right: string, hints?: {
|
|
1605
|
+
color?: string;
|
|
1606
|
+
tooltip?: string;
|
|
1607
|
+
noMark?: boolean;
|
|
1608
|
+
} | undefined);
|
|
1609
|
+
get length(): number;
|
|
1610
|
+
equals(other: FormulaLatexRangeNode): boolean;
|
|
1611
|
+
toLatex(): string;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
declare interface SVGConfig {
|
|
1615
|
+
width?: number;
|
|
1616
|
+
height?: number;
|
|
1617
|
+
fill?: string;
|
|
1618
|
+
stroke?: string;
|
|
1619
|
+
strokeWidth?: number;
|
|
1620
|
+
className?: string;
|
|
1621
|
+
preserveAspectRatio?: string;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Context passed to SVG generator functions when used in variables
|
|
1626
|
+
*/
|
|
1627
|
+
declare interface SVGGeneratorContext extends SVGConfig {
|
|
1628
|
+
value?: IValue;
|
|
1629
|
+
variable?: IVariable;
|
|
1630
|
+
environment?: IEnvironment;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
declare class Text_2 extends AugmentedFormulaNodeBase {
|
|
1634
|
+
id: string;
|
|
1635
|
+
body: AugmentedFormulaNode[];
|
|
1636
|
+
type: "text";
|
|
1637
|
+
constructor(id: string, body: AugmentedFormulaNode[]);
|
|
1638
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1639
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, }: {
|
|
1640
|
+
id?: string;
|
|
1641
|
+
parent?: AugmentedFormulaNode | null;
|
|
1642
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1643
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1644
|
+
body?: AugmentedFormulaNode[];
|
|
1645
|
+
}): Text_2;
|
|
1646
|
+
get children(): AugmentedFormulaNode[];
|
|
1647
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
export declare const unRegister: (name: string) => boolean;
|
|
1651
|
+
|
|
1652
|
+
declare class UnstyledRange {
|
|
1653
|
+
text: string;
|
|
1654
|
+
constructor(text: string);
|
|
1655
|
+
get length(): number;
|
|
1656
|
+
equals(other: FormulaLatexRangeNode): boolean;
|
|
1657
|
+
toLatex(): string;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Hook to access the Formulize context.
|
|
1662
|
+
* Returns null if not within FormulizeProvider, allowing components
|
|
1663
|
+
* to work both with context and with explicit props.
|
|
1664
|
+
*/
|
|
1665
|
+
export declare const useFormulize: () => FormulizeContextValue | null;
|
|
1666
|
+
|
|
1667
|
+
export declare const Variable: {
|
|
1668
|
+
/**
|
|
1669
|
+
* Generate variables by iterating over specified ranges.
|
|
1670
|
+
*
|
|
1671
|
+
* @param spec - Object defining loop variables and their ranges
|
|
1672
|
+
* @param generator - Function that generates [id, variable] pairs
|
|
1673
|
+
* @returns Object of variables
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* // Generate weight variables
|
|
1677
|
+
* Variable.loop({ i: [1, 4], j: [1, 3] }, ({ i, j }) => [
|
|
1678
|
+
* `w_${i}_${j}`,
|
|
1679
|
+
* { interaction: "drag", default: Math.random() - 0.5, range: [-2, 2] }
|
|
1680
|
+
* ])
|
|
1681
|
+
*/
|
|
1682
|
+
loop<T extends LoopSpec>(spec: T, generator: (context: LoopContext<T>, index: number) => [string, number | IVariableUserInput]): IVariablesUserInput;
|
|
1683
|
+
/**
|
|
1684
|
+
* Generate a grid of variables with naming pattern `{prefix}_{i}_{j}`.
|
|
1685
|
+
*
|
|
1686
|
+
* @param prefix - Variable name prefix
|
|
1687
|
+
* @param rows - Number of rows (or [startRow, endRow])
|
|
1688
|
+
* @param cols - Number of columns (or [startCol, endCol])
|
|
1689
|
+
* @param config - Variable configuration to apply to all
|
|
1690
|
+
* @returns Object of variables
|
|
1691
|
+
*
|
|
1692
|
+
* @example
|
|
1693
|
+
* // Generate 4x3 weight matrix
|
|
1694
|
+
* Variable.grid("w", 4, 3, { interaction: "drag", range: [-1, 1] })
|
|
1695
|
+
* // Produces: { w_1_1: {...}, w_1_2: {...}, ..., w_4_3: {...} }
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* // With random initialization
|
|
1699
|
+
* Variable.grid("w", 4, 3, {
|
|
1700
|
+
* interaction: "drag",
|
|
1701
|
+
* range: [-1, 1],
|
|
1702
|
+
* default: () => Math.random() * 2 - 1
|
|
1703
|
+
* })
|
|
1704
|
+
*/
|
|
1705
|
+
grid(prefix: string, rows: number | [number, number], cols: number | [number, number], config: Omit<IVariableUserInput, "default"> & {
|
|
1706
|
+
default?: number | (() => number);
|
|
1707
|
+
}): IVariablesUserInput;
|
|
1708
|
+
/**
|
|
1709
|
+
* Generate a vector of variables with naming pattern `{prefix}_{i}`.
|
|
1710
|
+
*
|
|
1711
|
+
* @param prefix - Variable name prefix
|
|
1712
|
+
* @param length - Number of elements (or [start, end] range)
|
|
1713
|
+
* @param config - Variable configuration to apply to all
|
|
1714
|
+
* @returns Object of variables
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* // Generate input vector
|
|
1718
|
+
* Variable.vector("x", 3, { interaction: "drag", default: 0.5 })
|
|
1719
|
+
* // Produces: { x_1: {...}, x_2: {...}, x_3: {...} }
|
|
1720
|
+
*/
|
|
1721
|
+
vector(prefix: string, length: number | [number, number], config: Omit<IVariableUserInput, "default"> & {
|
|
1722
|
+
default?: number | (() => number);
|
|
1723
|
+
}): IVariablesUserInput;
|
|
1724
|
+
/**
|
|
1725
|
+
* Create a single variable directly.
|
|
1726
|
+
*/
|
|
1727
|
+
create(id: string, config: number | IVariableUserInput): IVariablesUserInput;
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
declare class Variable_2 extends AugmentedFormulaNodeBase {
|
|
1731
|
+
id: string;
|
|
1732
|
+
body: AugmentedFormulaNode;
|
|
1733
|
+
variableLatex: string;
|
|
1734
|
+
originalSymbol: string;
|
|
1735
|
+
type: "variable";
|
|
1736
|
+
constructor(id: string, body: AugmentedFormulaNode, variableLatex: string, originalSymbol: string);
|
|
1737
|
+
toLatex(mode: LatexMode, offset: number): LatexRange;
|
|
1738
|
+
withChanges({ id, parent, leftSibling, rightSibling, body, variableLatex, originalSymbol, }: {
|
|
1739
|
+
id?: string;
|
|
1740
|
+
parent?: AugmentedFormulaNode | null;
|
|
1741
|
+
leftSibling?: AugmentedFormulaNode | null;
|
|
1742
|
+
rightSibling?: AugmentedFormulaNode | null;
|
|
1743
|
+
body?: AugmentedFormulaNode;
|
|
1744
|
+
variableLatex?: string;
|
|
1745
|
+
originalSymbol?: string;
|
|
1746
|
+
}): Variable_2;
|
|
1747
|
+
get children(): AugmentedFormulaNode[];
|
|
1748
|
+
toStyledRanges(): FormulaLatexRangeNode[];
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
declare type VariableSVGContent = string | ((ctx: SVGGeneratorContext) => SVGElement | string);
|
|
1752
|
+
|
|
1753
|
+
export declare const VisualizationComponent: default_2.FC<VisualizationComponentProps>;
|
|
1754
|
+
|
|
1755
|
+
declare interface VisualizationComponentProps {
|
|
1756
|
+
type: "plot2d" | "plot3d" | "custom";
|
|
1757
|
+
config: IVisualization;
|
|
1758
|
+
className?: string;
|
|
1759
|
+
style?: default_2.CSSProperties;
|
|
1760
|
+
width?: number | string;
|
|
1761
|
+
height?: number | string;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
export { }
|